[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [rtl] What is relationship between realtime interrupts
Hi Victor,
Why not implement POSIX 1003.1c fully and have normal mutexes and
condition variables. What you propose here is so close to that, it seem
strange that you don't implement standard POSIX. Note that the POSIX
1003.1c mutexes and convars are SMP safe. In posix, the normal
proceedure is (from Butenhof):
status = pthread_mutex_lock (&crew->mutex);
if (status != 0)
err_abort (status, "Lock crew mutex");
while (crew->work_count == 0) {
status = pthread_cond_wait (&crew->go, &crew->mutex);
if (status != 0)
err_abort (status, "Wait for go");
}
status = pthread_mutex_unlock (&crew->mutex);
if (status != 0)
err_abort (status, "Unlock mutex");
Regards, Stuart.
yodaiken@fsmlabs.com wrote:
>
> On Mon, Feb 21, 2000 at 01:35:45AM -0800, Robert Kavaler wrote:
> > > In the real-time task, use the following loop:
> That works and is the simple solution -- although it fails on SMP systems.
> I'm planning on making the Plan9 "sleep(conditionvar)" available
> this would do something like
> while(!conditionvar.cond){
> disable interrupts
> spinlock conditionvar.lock
> if(!conditionvar.cond){
> pthread_kill(pthread_self(),SUSPEND);
> unlock conditionvar.lock
> sigwait();
> }
> else {
> unlock conditionvar.lock
> return;
> }
> }
>