I'm programming on Unix in C.
I have 3 critical zones:
Mutex1 -> Lock
{
{ ZONE1
{
Mutex1 -> unLock
Mutex2 -> Lock
{
{ ZONE2
{
Mutex2 -> unLock
Mutex3 -> Lock
{
{ ZONE3
{
Mutex3 -> unLock
For each zone, there is a mutex. N processes execute this code, so mutexes are required to manage the critical areas. My problem is:
SIGINT is handled in this way -> signal(SIGINT, handler);
void handler(int sign)
{
exit(0);
}
If one process gets a signal (example ctrl+c) in a single critical area I need to unlock the mutex just taking into account where the process was when it received the signal (zone 1, zone 2, or zone 3).
What can I do to do this?