19 Mar
2006
19 Mar
'06
21:30
Pierre Patino wrote:
The problem is that my_write() can never get the A semaphore. The loop is too tight perhaps. Or maybe the system call has a lower priority than the kernel's worker thread. Other than using flags, is there some easy way to fix this?
You need to have both of your threads give up control of the CPU - do some IO for instance (through the OS, not direct). Or explicitly give up control with sched_yield(). Finally - I'm not sure, but doesn't the recent kernels have pre-emptive scheduling? Also, if you're on an SMP-machine doing direct(ish) IO, why not just spin-lock? /Per Jessen, Zurich