В Пт, 17/06/2022 в 08:11 -0600, Jacob Moody пишет:
> On 6/17/22 07:46, Thaddeus Woskowiak wrote:
> > I believe threadnotify() should be called from threadmain() to
> > properly register the handler in the rendez group
> 
> This is incorrect, according to thread(2):
> 
> "The thread library depends on all procs
> being in the same rendezvous group"


>From sleep(2):

    Alarm causes an alarm note (see notify(2)) to be sent to the
    invoking process after the number of milliseconds given by
    the argument.

Mean to be sent only to the invoking process, NOT to the process group.

> 
> The issue here is that your note handler has to call noted,
> you are returning from the handler without actually resuming the
> program.
> You either need to call noted(NCONT) to resume execution or
> noted(NDFLT)
> to stop execution.
> 
> An excerpt from notify(2):
> 
> "A notification handler must finish either by exiting the
> program or by calling noted; if the handler returns the
> behavior is undefined and probably erroneous."
> 
> So you are indeed observing undefined behavior.
> 

With:

------------------------------------
static int
handler_alarm(void *, char *msg)
{
        if(strstr(msg, "alarm")){
                noted(NCONT);
                return 1;
        }

        return 0;
}
------------------------------------

result the same:

cpu% 6.out | grep end | wc -l
     33


And noted(NCONT) may be needed, when process recieved many (2 and more)
notes at once.

May be something wrong  with interrupted an incomplete  system call?


> 
> Hope this helps,
> moody
> 


Regards,
Andrej





------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Tfa6823048ad90a21-M4fa69df14eff60273727c92b
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to