Putting a thread to sleep using schedule() is foolproof?

Jeff Haran Jeff.Haran at citrix.com
Wed Jun 11 14:45:38 EDT 2014



From: kernelnewbies-bounces at kernelnewbies.org [mailto:kernelnewbies-bounces at kernelnewbies.org] On Behalf Of Joshi
Sent: Wednesday, June 11, 2014 11:33 AM
To: Valdis.Kletnieks at vt.edu
Cc: kernelnewbies at kernelnewbies.org
Subject: Re: Putting a thread to sleep using schedule() is foolproof?

Is not changing the state to TASK_INTERRUPTIBLE before calling schedule() renders it not-schedulable? I thought task would be removed off run-queue by schedule() because it is in TASK_INTERRUPTIBLE state.

I was making a sort of task queue. Threads puts themselves into this queue when a resource(say memory-space) is not available. And other thread, post releasing the memory space, will wake the first thread in queue.
There are other means to achieve that, but I wondered why the above mentioned method did not succeed in making thread sleep.

I think TASK_INTERRUPTIBLE has to do with whether or not a task can be “interrupted” by a signal, as in wait_event_interruptible().

Jeff Haran

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140611/2b4e8505/attachment-0001.html 


More information about the Kernelnewbies mailing list