Ignore:
Timestamp:
Nov 19, 2020, 11:44:34 PM (3 years ago)
Author:
alain
Message:

1) Introduce up to 4 command lines arguments in the KSH "load" command.
These arguments are transfered to the user process through the
argc/argv mechanism, using the user space "args" vseg.

2) Introduce the named and anonymous "pipes", for inter-process communication
through the pipe() and mkfifo() syscalls.

3) Introduce the "chat" application to validate the two above mechanisms.

4) Improve printk() and assert() fonctions in printk.c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/alarm.h

    r23 r669  
    11/*
    2  * time.h: thread time related management
    3  *
    4  * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
    5  * Copyright (c) 2011,2012 UPMC Sorbonne Universites
     2 * alarm.h - timer based kernel alarm specification           
    63 *
    7  * This file is part of ALMOS-kernel.
     4 * Author     Alain Greiner (2016,2017,2018,2019,2020)
    85 *
    9  * ALMOS-kernel is free software; you can redistribute it and/or modify it
     6 * Copyright (c) UPMC Sorbonne Universites
     7 *
     8 * This file is part of ALMOS-MKH.
     9 *
     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 #ifndef _TIME_H_
    24 #define _TIME_H_
    2524
    26 #include <types.h>
     25#ifndef _ALARM_H_
     26#define _ALARM_H_
     27
     28#include <hal_kernel_types.h>
    2729#include <list.h>
    28 #include <device.h>
    2930
    30 struct event_s;
     31/****  Forward declarations  ****/
    3132
    32 struct alarm_info_s
     33struct  thread_s;
     34
     35/******************************************************************************************
     36 *   This structure defines a generic, timer based, kernel alarm.
     37 *
     38 * - An alarm being attached to a given thread, the alarm descriptor is embedded in the
     39 *   thread descriptor. A client thread can use the alarm_start() function to dynamically
     40 *   activate the alarm. It can use the alarm_stop() function to desactivate this alarm.
     41 * - This kernel alarm is generic, as the alarm handler (executed when the alarm rings),
     42 *   and the handler arguments are defined by two pointers <func_ptr> and <args_xp>.
     43 * - When an alarm is created by a client thread, it is registered in the list of alarms
     44 *   rooted in the core running the client thread. When it is stopped, the alarm is simply
     45 *   removed from this list.
     46 * - When creating an alarm, the client thread must define an absolute date (in cycles),
     47 *   the func_ptr local pointer, and the args_xp extended pointer.
     48 * - The list of alarms is ordered by increasing dates. At each TICK received by a core,
     49 *   the date of the first registered alarm is compared to the current date (in the
     50 *   core_clock() function). The alarm handler is executed when current_date >= alarm_date.
     51 * - It is the handler responsability to stop a ringing alarm, or update the date. 
     52 *
     53 * This mechanism is used bi the almos_mkh implementation of the TCP protocoL.
     54 ******************************************************************************************/
     55
     56typedef struct alarm_s
    3357{
    34         uint_t signature;
     58    cycle_t        date;           /*! absolute date for handler execution                */
     59    void         * func_ptr;       /*! local pointer on alarm handler function            */
     60    xptr_t         args_xp;        /*! local pointer on handler arguments                 */
     61    list_entry_t   list;           /*! all alarms attached to the same core               */
     62}
     63alarm_t;
    3564
    36         /* Public members */
    37         struct event_s *event;
     65/*******************************************************************************************
     66 * This defines the generic prototype for an alarm handler.
     67 ******************************************************************************************/
    3868
    39         /* Private members */
    40         uint_t tm_wakeup;
    41         struct list_entry list;
    42 };
     69typedef void (alarm_handler_t) ( xptr_t args_xp );
    4370
    44 struct alarm_s
    45 {
    46         struct list_entry wait_queue;
    47 };
     71/*******************************************************************************************
     72 * This function initializes the alarm descriptor embedded in the thread identified by the
     73 * <thread> argument from the <date>, <func_ptr>, <args_ptr> arguments, and registers it
     74 * in the ordered list rooted in the core running this <thread>.
     75 *******************************************************************************************
     76 * @ date       : absolute date (in cycles).
     77 * @ func_ptr   : local pointer on the handler to execute when the alarm rings.
     78 * @ args_xp    : extended pointer on the handler arguments.
     79 * @ thread     : local pointer on the client thread.
     80 ******************************************************************************************/
     81void alarm_start( cycle_t           date,
     82                  void            * func_ptr,
     83                  xptr_t            args_xp,
     84                  struct thread_s * thread );
     85
     86/*******************************************************************************************
     87 * This function updates the date of the alarm attached to the thread identified by the
     88 * <thread> argument. The list of alarms rooted in the core running the client thread
     89 * is modified to respect the absolute dates ordering.
     90 *******************************************************************************************
     91 * @ thread     : local pointer on the client thread.
     92 * @ new_date   : absolute new date (in cycles).
     93 ******************************************************************************************/
     94void alarm_update( struct thread_s * thread,
     95                   cycle_t           new_date );
     96
     97/*******************************************************************************************
     98 * This function unlink an alarm identified by the <thread> argument from the list of
     99 * alarms rooted in the core descriptor.
     100 *******************************************************************************************
     101 * @ thread     : local pointer on the client thread.
     102 ******************************************************************************************/
     103void alarm_stop( struct thread_s * thread );
    48104
    49105
    50 struct timeb {
    51         time_t         time;
    52         unsigned short millitm;
    53         short          timezone;
    54         short          dstflag;
    55 };
    56 
    57 struct timeval {
    58         clock_t tv_sec;    /* secondes */
    59         clock_t tv_usec;   /* microsecondes */
    60 };
    61 
    62 struct timezone {
    63         int tz_minuteswest;     /* minutes west of Greenwich */
    64         int tz_dsttime;         /* type of DST correction */
    65 };
    66 
    67 
    68 struct tms
    69 {
    70        clock_t tms_utime;  /* user time */
    71        clock_t tms_stime;  /* system time */
    72        clock_t tms_cutime; /* user time of children */
    73        clock_t tms_cstime; /* system time of children */
    74 };
    75 
    76 
    77 error_t alarm_manager_init(struct alarm_s *alarm);
    78 error_t alarm_wait(struct alarm_info_s *info, uint_t msec);
    79 
    80 void alarm_clock(struct alarm_s *alarm, uint_t ticks_nr);
    81 
    82 int sys_clock (uint64_t *val);
    83 int sys_alarm (unsigned nb_sec);
    84 int sys_ftime (struct timeb *utime);
    85 int sys_times(struct tms *utms);
    86 int sys_gettimeofday(struct timeval *tv, struct timezone *tz);
    87 
    88 #if CONFIG_THREAD_TIME_STAT
    89 struct thread_s;
    90 inline void tm_sleep_compute(struct thread_s *thread);
    91 inline void tm_usr_compute(struct thread_s *thread);
    92 inline void tm_sys_compute(struct thread_s *thread);
    93 inline void tm_wait_compute(struct thread_s *thread);
    94 inline void tm_exit_compute(struct thread_s *thread);
    95 inline void tm_born_compute(struct thread_s *thread);
    96 inline void tm_create_compute(struct thread_s *thread);
    97 
    98 #else
    99 
    100 #define tm_sleep_compute(thread)
    101 #define tm_usr_compute(thread)
    102 #define tm_sys_compute(thread)
    103 #define tm_wait_compute(thread)
    104 #define tm_exit_compute(thread)
    105 #define tm_born_compute(thread)
    106 #define tm_create_compute(thread)
    107 
    108 #endif  /* CONFIG_SCHED_STAT */
    109 
    110 #endif  /* _TIME_H_ */
     106#endif  /* _ALARM_H_ */
Note: See TracChangeset for help on using the changeset viewer.