18,11 → 18,11 |
|
/** |
------------ |
CVS : $Id: signal.c,v 1.8 2003-12-10 16:54:59 giacomo Exp $ |
CVS : $Id: signal.c,v 1.9 2004-03-09 08:53:18 giacomo Exp $ |
|
File: $File$ |
Revision: $Revision: 1.8 $ |
Last update: $Date: 2003-12-10 16:54:59 $ |
Revision: $Revision: 1.9 $ |
Last update: $Date: 2004-03-09 08:53:18 $ |
------------ |
|
This file contains: |
107,8 → 107,7 |
|
/* |
* A queue of all threads waiting in sigwait. |
* It is not static because it is used into the task_kill...ð |
*/ |
* It is not static because it is used into the task_kill...� */ |
static IQUEUE sigwaiters; |
|
|
1385,9 → 1384,10 |
|
/* Interrupt handling table */ |
static struct int_des { |
void (*fast)(int n); |
PID proc_index; |
BYTE isUsed; |
void (*fast)(int n); |
PID proc_index; |
BYTE isUsed; |
BYTE irqLock; |
} int_table[16]; |
|
/* Warning the interrupt can cause a preemption! */ |
1396,23 → 1396,25 |
|
void irq_fasthandler(void *n) |
{ |
int no = *(int *)n; |
PID p; |
int no = *(int *)n; |
PID p; |
|
/* tracer stuff */ |
TRACER_LOGEVENT(FTrace_EVT_interrupt_start,1,no,0); |
/* tracer stuff */ |
TRACER_LOGEVENT(FTrace_EVT_interrupt_start,1,no,0); |
|
if (int_table[no].fast != NULL) { |
kern_sti(); |
(int_table[no].fast)(no); |
kern_cli(); |
} |
if (int_table[no].fast != NULL) { |
if (int_table[no].irqLock == FALSE) |
kern_sti(); |
(int_table[no].fast)(no); |
if (int_table[no].irqLock == FALSE) |
kern_cli(); |
} |
|
TRACER_LOGEVENT(FTrace_EVT_interrupt_end,1,no,0); |
TRACER_LOGEVENT(FTrace_EVT_interrupt_end,1,no,0); |
|
/* If a sporadic process is linked,activate it */ |
p = int_table[no].proc_index; |
task_activate(p); // no problem if p == nil |
/* If a sporadic process is linked,activate it */ |
p = int_table[no].proc_index; |
task_activate(p); // no problem if p == nil |
} |
|
/*----------------------------------------------------------------------*/ |
1421,59 → 1423,60 |
/* If the fast parameter is NULL, no handler is called. */ |
/* If the pi parameter is NIL no task is installed */ |
/*----------------------------------------------------------------------*/ |
int handler_set(int no, void (*fast)(int n), PID pi) |
int handler_set(int no, void (*fast)(int n), PID pi, BYTE lock) |
{ |
SYS_FLAGS f; |
SYS_FLAGS f; |
|
if ((no < 1) || (no > 15)) { |
if ((no < 1) || (no > 15)) { |
errno = EWRONG_INT_NO; |
return -1; |
} |
} |
|
f = kern_fsave(); |
//kern_printf("handler_set: no %d pid %d\n",no, pi); |
if (int_table[no].isUsed == TRUE) { |
f = kern_fsave(); |
//kern_printf("handler_set: no %d pid %d\n",no, pi); |
if (int_table[no].isUsed == TRUE) { |
kern_frestore(f); |
errno = EUSED_INT_NO; |
return -1; |
} |
int_table[no].fast = fast; |
int_table[no].proc_index = pi; |
int_table[no].isUsed = TRUE; |
} |
int_table[no].fast = fast; |
int_table[no].proc_index = pi; |
int_table[no].isUsed = TRUE; |
int_table[no].irqLock = lock; |
|
irq_bind(no, irq_fasthandler, INT_FORCE); |
irq_unmask(no); |
kern_frestore(f); |
irq_bind(no, irq_fasthandler, INT_FORCE); |
irq_unmask(no); |
kern_frestore(f); |
|
return 1; |
return 1; |
} |
|
int handler_remove(int no) |
{ |
SYS_FLAGS f; |
SYS_FLAGS f; |
|
if (no < 1 || no > 15) { |
if (no < 1 || no > 15) { |
errno = EWRONG_INT_NO; |
return -1; |
} |
} |
|
f = kern_fsave(); |
if (int_table[no].isUsed == FALSE) { |
f = kern_fsave(); |
if (int_table[no].isUsed == FALSE) { |
kern_frestore(f); |
errno = EUNUSED_INT_NO; |
return -1; |
} |
} |
|
int_table[no].fast = NULL; |
int_table[no].proc_index = NIL; |
int_table[no].isUsed = FALSE; |
int_table[no].fast = NULL; |
int_table[no].proc_index = NIL; |
int_table[no].isUsed = FALSE; |
int_table[no].irqLock = FALSE; |
|
irq_bind(no,NULL, INT_PREEMPTABLE); |
irq_mask(no); |
kern_frestore(f); |
irq_bind(no,NULL, INT_PREEMPTABLE); |
irq_mask(no); |
kern_frestore(f); |
|
return 1; |
|
return 1; |
} |
|
/* this is the test that is done when a task is being killed |
1480,32 → 1483,29 |
and it is waiting on a sigwait */ |
static int signal_cancellation_point(PID i, void *arg) |
{ |
LEVEL l; |
LEVEL l; |
|
if (proc_table[i].status == WAIT_SIG) { |
if (proc_table[i].status == WAIT_SIG) { |
|
if (proc_table[i].delay_timer != -1) { |
kern_event_delete(proc_table[i].delay_timer); |
proc_table[i].delay_timer = -1; |
} |
if (proc_table[i].delay_timer != -1) { |
kern_event_delete(proc_table[i].delay_timer); |
proc_table[i].delay_timer = -1; |
} |
|
iq_extract(i, &sigwaiters); |
iq_extract(i, &sigwaiters); |
|
l = proc_table[i].task_level; |
level_table[l]->public_unblock(l,i); |
l = proc_table[i].task_level; |
level_table[l]->public_unblock(l,i); |
|
return 1; |
} |
else if (proc_table[i].status == WAIT_SIGSUSPEND) { |
return 1; |
} else if (proc_table[i].status == WAIT_SIGSUSPEND) { |
l = proc_table[i].task_level; |
level_table[l]->public_unblock(l,i); |
|
l = proc_table[i].task_level; |
level_table[l]->public_unblock(l,i); |
return 1; |
} |
|
return 1; |
} |
|
|
return 0; |
return 0; |
} |
|
void signals_init() |
1512,38 → 1512,38 |
{ |
int i; |
|
/* Initialize the default signal actions and the signal |
queue headers. */ |
/* Initialize the default signal actions and the signal queue headers. */ |
for (i = 0; i < SIG_MAX; i++) { |
sigactions[i].sa_handler = SIG_DFL; |
sigactions[i].sa_flags = 0; |
sigactions[i].sa_mask = 0; |
sigactions[i].sa_sigaction = 0; |
sigqueued[i] = -1; |
} |
sigactions[i].sa_handler = SIG_DFL; |
sigactions[i].sa_flags = 0; |
sigactions[i].sa_mask = 0; |
sigactions[i].sa_sigaction = 0; |
sigqueued[i] = -1; |
} |
|
/* Initialize the signal queue */ |
for (i=0; i < SIGQUEUE_MAX-1; i++) { |
sig_queue[i].next = i+1; |
sig_queue[i].flags = 0; |
} |
sig_queue[SIGQUEUE_MAX-1].next = NIL; |
sig_queue[SIGQUEUE_MAX-1].flags = 0; |
sigqueue_free = 0; |
/* Initialize the signal queue */ |
for (i=0; i < SIGQUEUE_MAX-1; i++) { |
sig_queue[i].next = i+1; |
sig_queue[i].flags = 0; |
} |
sig_queue[SIGQUEUE_MAX-1].next = NIL; |
sig_queue[SIGQUEUE_MAX-1].flags = 0; |
sigqueue_free = 0; |
|
procsigpending = 0; |
procsigpending = 0; |
|
iq_init(&sigwaiters, &freedesc, 0); |
alarm_timer = -1; |
iq_init(&sigwaiters, &freedesc, 0); |
alarm_timer = -1; |
|
/* Interrupt handling init */ |
for (i=0; i<16; i++) { |
int_table[i].fast = NULL; |
int_table[i].proc_index = NIL; |
int_table[i].isUsed = FALSE; |
} |
/* Interrupt handling init */ |
for (i=0; i<16; i++) { |
int_table[i].fast = NULL; |
int_table[i].proc_index = NIL; |
int_table[i].isUsed = FALSE; |
int_table[i].irqLock = FALSE; |
} |
|
register_cancellation_point(signal_cancellation_point, NULL); |
register_cancellation_point(signal_cancellation_point, NULL); |
} |
|
|