source: trunk/kernel/kern/signal.c @ 534

Last change on this file since 534 was 457, checked in by alain, 6 years ago

This version modifies the exec syscall and fixes a large number of small bugs.
The version number has been updated (0.1)

File size: 2.4 KB
RevLine 
[1]1/*
2 * signal.c - signal-management related operations implementation
3 *
[409]4 * Author  Ghassan Almaless (2008,2009,2010,2011,2012)
5 *         Mohamed Lamine Karaoui (2015)
6 *         Alain Greiner    (2016,2017)
[1]7 *
8 * Copyright (c) UPMC Sorbonne Universites
9 *
10 * This file is part of ALMOS-MKH.
11 *
12 * ALMOS-MKH is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; version 2.0 of the License.
15 *
16 * ALMOS-MKH is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
23 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
[457]26#include <hal_kernel_types.h>
[23]27#include <printk.h>
[1]28#include <signal.h>
29
[23]30/*
31
32SIGNAL_HANDLER(kill_sigaction)
[1]33{
[23]34        thread_s * this = CURRENT_THREAD;
[1]35
[407]36        printk("\n[DBG] %s : threadReceived signal %d, pid %d, tid %x, core %d  [ KILLED ]\n",
[23]37               sig,
38               this->process->pid,
39               this,
40               cpu_get_id());
[1]41
[23]42        sys_thread_exit((void*)EINTR);
[1]43}
44
[23]45///////////////////////////////////////////////
46void signal_manager_init( process_t * process )
[1]47{
[23]48        memset(&process->sig_mgr, 0, sizeof(process->sig_mgr));
49        process->sig_mgr.sigactions[SIGCHLD] = SIG_IGNORE;
50        process->sig_mgr.sigactions[SIGURG]  = SIG_IGNORE;
51}
[1]52
[5]53
[23]54/////////////////////////////////////
55void signal_notify( thread_t * this )
[1]56{
[23]57        uint32_t     sig_state;
58        uint32_t     sig;
59        sig_mgr_t  * sig_mgr;
60        uint32_t     irq_state;
[1]61
[23]62        sig_state = this->signals;
[1]63        sig       = 0;
64 
65        while((sig_state != 0) && ((sig_state & 0x1) == 0) && (sig < SIG_NR))
66        {
67                sig ++;
68                sig_state >>= 1;
69        }
70 
71        if(sig)
72        {
73                cpu_disable_all_irq(&irq_state);
74
75                if(thread_isSignaled(this))
76                {
77                        cpu_restore_irq(irq_state);
78                        return;
79                }
80
81                thread_set_signaled(this);
82                cpu_restore_irq(irq_state);
83
84                spinlock_lock(&this->lock);
85                this->info.sig_state &= ~(1 << sig);
86                spinlock_unlock(&this->lock);
87
88                sig_mgr = &this->process->sig_mgr;
89
90                if(sig_mgr->sigactions[sig] == SIG_IGNORE)
91                        return;
92
93                if(sig_mgr->sigactions[sig] == SIG_DEFAULT)
94                        kill_sigaction(sig);
95
96                cpu_signal_notify(this, sig_mgr->sigactions[sig], sig);
97        }
98}
[23]99*/
Note: See TracBrowser for help on using the repository browser.