This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Timeslicing with mutexes


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
> function.
> 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
again.

Jifl
-- 
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]