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

Re: device drivers again



In article <m0uN2lL-00033TC@tsunx.ctn.cogs.susx.ac.uk>, "James Cox" <jamesco@cogs.susx.ac.uk> writes:

|> Could someone explain to me how you use the kernal functions:
|>     sleep(word que, long cond)

|> and...

|>     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'?

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.