Changeset 23 for trunk/kernel/syscalls/sys_alarm.c
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_alarm.c
r1 r23 1 1 /* 2 * kern/sys_alarm.c - timed sleep/wakeup2 * sys_alarm.c - timed sleep/wakeup 3 3 * 4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless 5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites 4 * Author Alain Greiner (2016,2017) 5 * 6 * Copyright (c) UPMC Sorbonne Universites 6 7 * 7 * This file is part of ALMOS- kernel.8 * This file is part of ALMOS-MKH. 8 9 * 9 * ALMOS- kernelis free software; you can redistribute it and/or modify it10 * ALMOS-MKH is free software; you can redistribute it and/or modify it 10 11 * under the terms of the GNU General Public License as published by 11 12 * the Free Software Foundation; version 2.0 of the License. 12 13 * 13 * ALMOS- kernelis distributed in the hope that it will be useful, but14 * ALMOS-MKH is distributed in the hope that it will be useful, but 14 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 17 18 * 18 19 * You should have received a copy of the GNU General Public License 19 * along with ALMOS- kernel; if not, write to the Free Software Foundation,20 * along with ALMOS-MKH; if not, write to the Free Software Foundation, 20 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 22 */ 22 23 23 #include < types.h>24 #include <hal_types.h> 24 25 #include <thread.h> 26 #include <printk.h> 25 27 #include <cluster.h> 26 #include <task.h> 27 #include <time.h> 28 #include <process.h> 28 29 #include <scheduler.h> 29 #include <cpu.h> 30 #include <cpu-trace.h> 30 #include <core.h> 31 31 32 EVENT_HANDLER(sys_alarm_event_handler) 32 //////////////////////////////// 33 int sys_alarm( uint64_t cycles ) 33 34 { 34 struct thread_s *thread; 35 thread_t * this = CURRENT_THREAD; 36 process_t * process = this->process; 35 37 36 thread = event_get_argument(event); 37 sched_wakeup(thread); 38 return 0; 39 } 40 41 int sys_alarm (unsigned nb_sec) 42 { 43 struct thread_s *this; 44 struct event_s event; 45 struct alarm_info_s info; 46 47 if( nb_sec == 0) 48 return 0; 49 50 this = current_thread; 51 event_set_handler(&event, &sys_alarm_event_handler); 52 event_set_priority(&event, E_FUNC); 53 event_set_argument(&event,this); 54 info.event = &event; 55 56 alarm_wait(&info, nb_sec * 4); 57 sched_sleep(this); 58 return 0; 38 printk("\n[ERROR] in %s for thread %x in process %x : not implemented yet\n", 39 __FUNCTION__ , this->trdid , process->pid ); 40 this->errno = EFAULT; 41 return -1; 59 42 } 60 43 61 44 45
Note: See TracChangeset
for help on using the changeset viewer.