[mercury-users] problem with signals

Ralph Becket rafe at cs.mu.OZ.AU
Thu Mar 6 10:21:26 AEDT 2003


pieter.laeremans at student.kuleuven.ac.be, Wednesday,  5 March 2003:
> 
> Now I would like to prevent that the callbackhandler would be invoked
> while I'm processing the data.  Frome the source code of liblnp I have
> inferred that the supplied callback function is registered as signal
> handler for the SIGIO signal.  

Two things.

1. You could write the callback in Mercury an export it to C.  This way
you could use the Mercury concurrency tools in extras rather than
whatever C library happens to be around to do the job.

2. Why not have two semaphores, one for the Mercury side and one for
the callback?

Callback Side
	sem_wait(callback_can_run);
	...
	sem_signal(mercury_can_run);

Mercury Side
	sem_wait(mercury_can_run);
	sem_wait(callback_can_run);   /* Prevent simultaneous callback */
	...
	sem_signal(callback_can_run); /* Reenable callback */

- Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list