This is the mail archive of the
mailing list for the eCos project.
Re: Timeslicing with mutexes
- From: Jonathan Larmour <jlarmour at redhat dot com>
- To: Stijn Symons <stijn dot symons at acunia dot com>
- Cc: "ecos-discuss" <ecos-discuss at sources dot redhat dot com>
- Date: Wed, 27 Feb 2002 20:02:05 +0000
- Subject: Re: [ECOS] Timeslicing with mutexes
- Organization: Red Hat UK Ltd.
- References: <3C7A4735.8AEE9522@acunia.com>
Stijn Symons wrote:
> Hi all,
> I have a stange situation at hand. I have to implement a method to lock
> a mutex with a timeout. I do this with 2 mutexes and a condition
> variable. When the mutex is locked by thread 1 and thread 2 wants to
> lock, i wait for a period (timeout ticks) with the cyg_cond_timed_wait
> My mutex_unlock function will signal the condition if it's unlocked. So
> i presume that when i give this signal, the timed_wait will continue
> directly without waiting for the timeslice to go off.
Only if the thread that had been waiting is higher priority.
> But when I test it, it doesn't work. So does ecos continue until the
> timeslice is over or will it directly go to the code after the
> cyg_cond_timed_wait function?
Also note that once signalled, the waiting thread will try and acquire the
mutex associated with the condition variable. It might be that's not
working, e.g. if you haven't unlocked it before waiting on the cond var
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss