[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: device drivers again

James Cox:

>Could someone explain to me how you use the kernal functions:
>    sleep(word que, long cond)
>    wake(word que, long cond)
>I'm sure they're really usefull, but in both the Atari ocmpendium and the MiNT
>documentation, the explanation is simply 'sleep/wake a process waiting for
>condition 'cond' on que 'que'' which isn't very helpful.
>What are valid values for 'que' and 'cond'?

Andreas Schwab:
>que is one of the queues where you want the process to be on, eg IO_Q,
>SELECT_Q (the names are defined somewhere in the sources).  cond is an
>arbitrary value that you can use to distinguish between different wait
>conditions.  wake will only wake up a process that has been put to
>sleep using the same value for cond.  The kernel does not interpret
>the value in any other way.
>Eg. a device driver that wants to put a process to sleep that waits
>for I/O on the device might call sleep(IO_Q, dev_id), where dev_id
>identifies the device that the process waits on.  Later if an
>interrupt or whatever can provide data from the device it will call
>wake(IO_Q, dev_id) that will wake up every process that sleeps on the
>IO_Q for condition dev_id.

Does it make any difference which queue the process is put to sleep
on?  AFAICT, if you're using a unique value for cond, any processes you
put to sleep using it will only be woken up when the same value of cond
is used.  This would mean that it doesn't matter which queues I use
(except the run queue!), and I can essentially treat all the queues as
private to my driver.

Is this correct?  Are there any situations where all the processes on a
queue are woken, regardless of their value of cond?