Frage

Can someone point me in the right direction on how to implement kernel threads for a producer consumer scenario? Also if someone could show me how to use kernel's doubly linked list (bounded buffer) in the implementation of this example.

I so far understand how to initialize and use the pthreads, and mutexes for the synchronization of the program, but I cant seem to figure out how to do it with kernel threads.

The prog lang. im using is C

War es hilfreich?

Lösung

For the conceptual part, you can read Robert Love's Linux Kernel Development. The book generally says you can use functions like

struct task_struct * kthread_create (...);

struct task_struct * kthread_run (...);

struct task_struct * kthread_stop (...);

to manage threads. Threads are actually light-weight processes in the kernel. So you would need to do your homework on processes as well, if you haven't done so.

For the consumer-producer problem, here's an example using pthread.

Hope this helps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top