Skip to contentSkip to conversation

TASK_EXCLUSIVE?

DISCUSSION [email protected] 2 participants 2 messages Jul 26, 2001

lore
Share & tools
lore
#0 lore raw

I was reading through the new edition of Linux Device Drivers and decided to try the TASK_EXCLUSIVE flag to get a single member of a wait queue to wake. I get a compile error though that it is undeclared. Grepping the kernel source came up with nothing.

Did something change before the book went to press? I seem to recall reading something here about that but can't come up with anything searching the archives. Maybe I'm just misremembering. At any rate it seems to have gone somewhere...can somebody point me at its replacement? Does WQ_FLAG_EXCLUSIVE do the job?

Tim

#1 lore raw
Quoted 4 lines · On Wed, 25 Jul 2001 [email protected] wrote:

I was reading through the new edition of Linux Device Drivers and decided to try the TASK_EXCLUSIVE flag to get a single member of a wait queue to wake. I get a compile error though that it is undeclared. Grepping the kernel source came up with nothing.

the 2.4 waitqueue interface has changed as part of the wake-some semantics introduced for the block-IO-scheduler changes. Wake-some is more generic than wake-one. The new way to add a wake-some task to a waitqueue is to use the add_wait_queue_exclusive() function. To add a 'wake-all' task you should use the well-known add_wait_queue() function.

TASK_EXCLUSIVE was an interim implementation that supported wake-one only. The new implementation enables a task to be on multiple waitqueues with different wake-up semantics, because there is now a per-waitqueue-entry attribute, not a per-task (and thus global) attribute for wake-some semantics.

When a wake_up_nr(N) wakeup event comes, all wake-all tasks will be woken up, and 'N' wake-some tasks. The 'old' wake_up() function is wake_up_nr(1). Wake-one is a special case of wake-some, where N = 1. There is also a new wake_up_all() function that wakes up all tasks disregarding their wake-up attribute, including all wake-some tasks.

current usage of these interfaces: most places in the kernel use wake_up() and use wake-all tasks - like they did for years. 'Old' code that does not need to optimize waitqueue behavior behaves in the expected way. Networking, the semaphore code, the pagecache locking code and some other places uses wake-one waitqueues. Certain parts of networking use a mixed waitqueue with wake-some and wake-all tasks. The block IO scheduler uses wake-some to signal the completion of multiple IO slots. wake_up_all() is used in a couple of places as well, like TUX [ :-) ], to eg. deregister all wake-one worker threads with a single call.

Ingo