[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: eCos port
- From: Savin Zlobec <savin@...>
- Date: Thu, 17 Jul 2003 15:47:06 +0200
Roberto Ierusalimschy wrote:
Is this safe ?
Yes. (But it only works when there is a hook.) You can also add those
lines outside that "if" (but then you have a higher perfomance penalty).
-- Roberto
PS: Actually you do not need that code. All you need is a count
hook. Lua unlocks its mutex before calling the hook.
Actually the unlock/lock get's called every time (I've broke the if statement there!).
I thought about using a count hook - but just unlocking and then locking again seemd
much more simple, since with a hook I need an alarm to set the hook if the current
thread has had its share of time.
The situation I'am worried about with unlock/lock (inside main interpreter loop)
is a case where thread A running lua with state L1 gets preempted by thread B wich
calls a lua script with state L1 (same state).
I've had a closer look at hooks and now I see it is the safest way.
thanks
savin