Ignore:
Timestamp:
Jun 18, 2017, 10:06:41 PM (5 years ago)
Author:
alain
Message:

Introduce syscalls.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/syscalls/sys_alarm.c

    r1 r23  
    11/*
    2  * kern/sys_alarm.c - timed sleep/wakeup
     2 * sys_alarm.c - timed sleep/wakeup
    33 *
    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
    67 *
    7  * This file is part of ALMOS-kernel.
     8 * This file is part of ALMOS-MKH.
    89 *
    9  * ALMOS-kernel is free software; you can redistribute it and/or modify it
     10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
    1011 * under the terms of the GNU General Public License as published by
    1112 * the Free Software Foundation; version 2.0 of the License.
    1213 *
    13  * ALMOS-kernel is distributed in the hope that it will be useful, but
     14 * ALMOS-MKH is distributed in the hope that it will be useful, but
    1415 * WITHOUT ANY WARRANTY; without even the implied warranty of
    1516 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     
    1718 *
    1819 * 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,
    2021 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    2122 */
    2223
    23 #include <types.h>
     24#include <hal_types.h>
    2425#include <thread.h>
     26#include <printk.h>
    2527#include <cluster.h>
    26 #include <task.h>
    27 #include <time.h>
     28#include <process.h>
    2829#include <scheduler.h>
    29 #include <cpu.h>
    30 #include <cpu-trace.h>
     30#include <core.h>
    3131
    32 EVENT_HANDLER(sys_alarm_event_handler)
     32////////////////////////////////
     33int sys_alarm( uint64_t cycles )
    3334{
    34         struct thread_s *thread;
     35    thread_t  * this    = CURRENT_THREAD;
     36    process_t * process = this->process;
    3537
    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;
    5942}
    6043
    6144
     45
Note: See TracChangeset for help on using the changeset viewer.