Ignore:
Timestamp:
Oct 1, 2015, 4:20:46 PM (9 years ago)
Author:
alain
Message:

Major release: Change the task model to implement the POSIX threads API.

  • The shell "exec" and "kill" commands can be used to activate/de-activate the applications.
  • The "pause", "resume", and "context" commands can be used to stop, restart, a single thtead or to display the thread context.

This version has been tested on the following multi-threaded applications,
that have been modified to use the POSIX threads:

  • classif
  • convol
  • transpose
  • gameoflife
  • raycast
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_kernel/sys_handler.h

    r707 r709  
    1616#include "kernel_locks.h"
    1717#include "stdio.h"
     18
     19///////////////////////////////////////////////////////////////////////////////
     20// Define the possible command values for the giet_pthread_control() syscall
     21///////////////////////////////////////////////////////////////////////////////
     22
     23#define THREAD_CMD_PAUSE        0
     24#define THREAD_CMD_RESUME       1
     25#define THREAD_CMD_CONTEXT      2
     26
     27///////////////////////////////////////////////////////////////////////////////
     28// Define the error codes for the thread related syscalls
     29///////////////////////////////////////////////////////////////////////////////
     30
     31#define GIET_SYSCALL_OK                               ( 0 )
     32#define GIET_SYSCALL_VSPACE_NOT_FOUND                 (-1 )
     33#define GIET_SYSCALL_THREAD_NOT_FOUND                 (-2 )
     34#define GIET_SYSCALL_NOT_IN_SAME_VSPACE               (-3 )
     35#define GIET_SYSCALL_UNCOHERENT_THREAD_CONTEXT        (-4 )
     36#define GIET_SYSCALL_ILLEGAL_THREAD_COMMAND_TYPE      (-5 )
     37#define GIET_SYSCALL_CANNOT_LOAD_DATA_SEGMENT         (-6 )
     38#define GIET_SYSCALL_THREAD_ALREADY_ACTIVE            (-7 )
     39#define GIET_SYSCALL_MAIN_NOT_FOUND                   (-8 )
     40#define GIET_SYSCALL_APPLI_CANNOT_BE_KILLED           (-9 )
     41#define GIET_SYSCALL_PTHREAD_ARGUMENT_NOT_SUPPORTED   (-10)
     42#define GIET_SYSCALL_ILLEGAL_CLUSTER_COORDINATES      (-11)
     43#define GIET_SYSCALL_VSEG_NOT_FOUND                   (-12)
     44#define GIET_SYSCALL_UNDEFINED_SYSTEM_CALL            (-13)
     45#define GIET_SYSCALL_COPROCESSOR_NOT_FOUND            (-14)
     46#define GIET_SYSCALL_COPROCESSOR_ILLEGAL_MODE         (-15)
    1847
    1948///////////////////////////////////////////////////////////////////////////////
     
    86115
    87116
    88 
    89 
    90 ///////////////////////////////////////////////////////////////////////////////
    91 //    Coprocessors related syscall handlers
    92 ///////////////////////////////////////////////////////////////////////////////
    93 
    94 int _sys_coproc_register_set( unsigned int cluster_xy,
    95                               unsigned int reg_index,
    96                               unsigned int value );
    97 
    98 int _sys_coproc_register_get( unsigned int  cluster_xy,
    99                               unsigned int  reg_index,
    100                               unsigned int* buffer );
    101 
    102 int _sys_coproc_alloc( unsigned int   coproc_type,
    103                        unsigned int*  coproc_info );
    104 
    105 int _sys_coproc_release( unsigned int coproc_reg_index );
    106 
    107 int _sys_coproc_channel_init( unsigned int            channel,
    108                               giet_coproc_channel_t*  desc );
    109 
    110 int _sys_coproc_run( unsigned int coproc_reg_index );
    111 
    112 int _sys_coproc_completed();
     117//////////////////////////////////////////////////////////////////////////////
     118//           Applications related syscall handlers
     119//////////////////////////////////////////////////////////////////////////////
     120
     121extern int _sys_kill_application( char* name );
     122
     123extern int _sys_exec_application( char* name );
     124
     125extern int _sys_applications_status();
     126
     127/////////////////////////////////////////////////////////////////////////////
     128//          Threads related syscall handlers
     129/////////////////////////////////////////////////////////////////////////////
     130
     131extern int _sys_pthread_create( unsigned int*  buffer,
     132                                void*          attr,
     133                                void*          function,
     134                                void*          arg );
     135
     136extern int _sys_pthread_join( unsigned int  trdid,
     137                              void*         ptr );
     138
     139extern int _sys_pthread_kill( unsigned int  trdid,
     140                              int           signal );
     141
     142extern int _sys_pthread_exit( void* string);
     143
     144extern int _sys_pthread_yield();
     145
     146extern int _sys_pthread_control( unsigned int  command,
     147                                 char*         vspace_name,
     148                                 char*         thread_name );
     149
     150///////////////////////////////////////////////////////////////////////////////
     151//          Coprocessors related syscall handlers
     152///////////////////////////////////////////////////////////////////////////////
     153
     154extern int _sys_coproc_alloc( unsigned int   coproc_type,
     155                              unsigned int*  coproc_info );
     156
     157extern int _sys_coproc_release( unsigned int coproc_reg_index );
     158
     159extern int _sys_coproc_channel_init( unsigned int            channel,
     160                                     giet_coproc_channel_t*  desc );
     161
     162extern int _sys_coproc_run( unsigned int coproc_reg_index );
     163
     164extern int _sys_coproc_completed();
    113165
    114166///////////////////////////////////////////////////////////////////////////////
     
    116168///////////////////////////////////////////////////////////////////////////////
    117169
    118 int _sys_tty_alloc( unsigned int shared );
    119 
    120 int _sys_tty_release();
    121 
    122 int _sys_tty_write( const char*  buffer,
     170extern int _sys_tty_alloc( unsigned int shared );
     171
     172extern int _sys_tty_release();
     173
     174extern int _sys_tty_write( const char*  buffer,
    123175                    unsigned int length,
    124176                    unsigned int channel );
    125177
    126 int _sys_tty_read(  char*        buffer,
     178extern int _sys_tty_read(  char*        buffer,
    127179                    unsigned int length,
    128180                    unsigned int channel );
     
    132184//////////////////////////////////////////////////////////////////////////////
    133185
    134 int _sys_tim_alloc();
    135 
    136 int _sys_tim_release();
    137 
    138 int _sys_tim_start( unsigned int period );
    139 
    140 int _sys_tim_stop();
     186extern int _sys_tim_alloc();
     187
     188extern int _sys_tim_release();
     189
     190extern int _sys_tim_start( unsigned int period );
     191
     192extern int _sys_tim_stop();
    141193
    142194//////////////////////////////////////////////////////////////////////////////
     
    144196//////////////////////////////////////////////////////////////////////////////
    145197
    146 int _sys_nic_alloc( unsigned int is_rx,
    147                     unsigned int xmax,
    148                     unsigned int ymax );
    149 
    150 int _sys_nic_release( unsigned int is_rx );
    151 
    152 int _sys_nic_start( unsigned int is_rx,
    153                     unsigned int channel );
    154 
    155 int _sys_nic_move( unsigned int is_rx,
    156                    unsigned int channel,
    157                    void*        buffer );
    158 
    159 int _sys_nic_stop( unsigned int is_rx,
    160                    unsigned int channel );
    161 
    162 int _sys_nic_clear( unsigned int is_rx,
    163                     unsigned int channel );
    164 
    165 int _sys_nic_stats( unsigned int is_rx,
    166                     unsigned int channel );
     198extern int _sys_nic_alloc( unsigned int is_rx,
     199                           unsigned int xmax,
     200                           unsigned int ymax );
     201
     202extern int _sys_nic_release( unsigned int is_rx );
     203
     204extern int _sys_nic_start( unsigned int is_rx );
     205
     206extern int _sys_nic_move( unsigned int is_rx,
     207                          void*        buffer );
     208
     209extern int _sys_nic_stop( unsigned int is_rx );
     210
     211extern int _sys_nic_clear( unsigned int is_rx );
     212
     213extern int _sys_nic_stats( unsigned int is_rx );
    167214
    168215//////////////////////////////////////////////////////////////////////////////
     
    170217//////////////////////////////////////////////////////////////////////////////
    171218
    172 int _sys_fbf_sync_write( unsigned int offset,
     219extern int _sys_fbf_sync_write( unsigned int offset,
    173220                         void*        buffer,
    174221                         unsigned int length );
    175222
    176 int _sys_fbf_sync_read(  unsigned int offset,
     223extern int _sys_fbf_sync_read(  unsigned int offset,
    177224                         void*        buffer,
    178225                         unsigned int length );
    179226
    180 int _sys_fbf_cma_alloc();
    181 
    182 int _sys_fbf_cma_release();
    183 
    184 int _sys_fbf_cma_init_buf(void*        buf0_vbase,
     227extern int _sys_fbf_cma_alloc();
     228
     229extern int _sys_fbf_cma_release();
     230
     231extern int _sys_fbf_cma_init_buf(void*        buf0_vbase,
    185232                          void*        buf1_vbase,
    186233                          void*        sts0_vaddr,
    187234                          void*        sts1_vaddr );
    188235
    189 int _sys_fbf_cma_start( unsigned int length );
    190 
    191 int _sys_fbf_cma_display( unsigned int buffer_index );
    192 
    193 int _sys_fbf_cma_stop();
     236extern int _sys_fbf_cma_start( unsigned int length );
     237
     238extern int _sys_fbf_cma_display( unsigned int buffer_index );
     239
     240extern int _sys_fbf_cma_stop();
    194241
    195242//////////////////////////////////////////////////////////////////////////////
     
    197244//////////////////////////////////////////////////////////////////////////////
    198245
    199 int _sys_ukn();
    200 
    201 int _sys_proc_xyp( unsigned int* x,
     246extern int _sys_ukn();
     247
     248extern int _sys_proc_xyp( unsigned int* x,
    202249                   unsigned int* y,
    203250                   unsigned int* p );
    204251
    205 int _sys_task_exit( char* string );
    206 
    207 int _sys_kill_application( char* name );
    208 
    209 int _sys_exec_application( char* name );
    210 
    211 int _sys_context_switch();
    212 
    213 int _sys_local_task_id();
    214 
    215 int _sys_global_task_id();
    216 
    217 int _sys_thread_id();
    218 
    219 int _sys_procs_number( unsigned int* x_size,
     252extern int _sys_procs_number( unsigned int* x_size,
    220253                       unsigned int* y_size,
    221254                       unsigned int* nprocs );
    222255
    223 int _sys_vseg_get_vbase( char*         vspace_name,
     256extern int _sys_vseg_get_vbase( char*         vspace_name,
    224257                         char*         vseg_name,
    225258                         unsigned int* vbase );
    226259
    227 int _sys_vseg_get_length( char*         vspace_name,
     260extern int _sys_vseg_get_length( char*         vspace_name,
    228261                          char*         vseg_name,
    229262                          unsigned int* length );
    230263
    231 int _sys_xy_from_ptr( void*          ptr,
     264extern int _sys_xy_from_ptr( void*          ptr,
    232265                      unsigned int*  x,
    233266                      unsigned int*  y );
    234267
    235 int _sys_heap_info( unsigned int* vaddr,
     268extern int _sys_heap_info( unsigned int* vaddr,
    236269                    unsigned int* length,
    237270                    unsigned int  x,
    238271                    unsigned int  y );
    239 
    240 int _sys_tasks_status();
    241 
    242 int _sys_fat_read( unsigned int fd_id,
    243                    unsigned int buffer,
    244                    unsigned int count );
    245272
    246273#endif
Note: See TracChangeset for help on using the changeset viewer.