[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: SPAM-LOW: answer to the sample question
- From: "Tales Aguiar" <tqueiroz@...>
- Date: Mon, 27 Jun 2005 13:29:03 -0300
On my IDE, I put a cancel button to stop the execution of script.
I wrote one function called 'SafeHook' and register it by 'lua_sethook'.
The code of SafeHook test the button and raise an exception to break the
All works fine! I have a lot of script running perfectly. But your code,
specifically, have this diagnostic.
I think about coroutine, is the unique library that I don't test. I don't do
nothing to specil to coroutine.
Can I be lacking some thing?
PS.: I an brazilian and have a very bad english.. sorry and thanks.
----- Original Message -----
From: "Customer Support" <email@example.com>
Sent: Saturday, June 25, 2005 10:31 AM
Subject: SPAM-LOW: answer to the sample question
> Tales Aguiar writes:
> "I put it and run.. in my case the program frezze!! ...(snip)...
> What can be happening?"
> The correct answer is d) There is no output.
> This code is a simple producer-consumer relationship. In this case there
> are no conditions that will stop either the producer or the consumer so
> code will never reach line 29. Consequently there will be no output.
> Here is the code again if you missed it.
> Given the following code:
> > 1 x = 0
> > 2
> > 3 prod = coroutine.create(
> > 4 function()
> > 5 while true do
> > 6 put(x)
> > 7 x = x + 2
> > 8 end
> > 9 end)
> > 10
> > 11 cons = coroutine.create(
> > 12 function(p)
> > 13 while true do
> > 14 get(p)
> > 15 end
> > 16 end)
> > 17
> > 18 function put(x)
> > 19 coroutine.yield(x)
> > 20 end
> > 21
> > 22 function get(p)
> > 23 local status, value = coroutine.resume(p)
> > 24 return value
> > 25 end
> > 26
> > 27 coroutine.resume(prod)
> > 28 coroutine.resume(cons, prod)
> > 29 print(coroutine.status())
> > What is the output?
> > a) dead
> > b) running
> > c) suspended
> > d) There is no output. (on the test, this is a different font so that
> > you can see it is an answer, not a quote of output)
> > e) An error occurs. (ditto)
> R. Grant Reed
> High-Level Certifications