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_drivers/tty_driver.c

    r605 r709  
    1919
    2020////////////////////////////////////////////////////////////////////////////////////
     21//               extern variables
     22////////////////////////////////////////////////////////////////////////////////////
     23
     24// This variable is allocated in kernel_init.c file
     25extern static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX];
     26
     27////////////////////////////////////////////////////////////////////////////////////
    2128//               global variables
    2229////////////////////////////////////////////////////////////////////////////////////
    2330
     31__attribute__((section(".kdata")))
     32tty_fifo_t  _tty_rx_fifo[NB_TTY_CHANNELS];
     33
     34/*
    2435__attribute__((section(".kdata")))
    2536unsigned int   _tty_rx_buf[NB_TTY_CHANNELS];
     
    2738__attribute__((section(".kdata")))
    2839unsigned int   _tty_rx_full[NB_TTY_CHANNELS];
     40
     41__attribute__((section(".kdata")))
     42unsigned int   _tty_rx_trdid[NB_TTY_CHANNELS];
     43*/
    2944
    3045////////////////////////////////////////////////////////////////////////////////////
     
    5267void _tty_init( unsigned int channel )
    5368{
    54     _tty_rx_full[channel] = 0;
     69    _tty_rx_fifo[channel].sts = 0;
     70    _tty_rx_fifo[channel].ptr = 0;
     71    _tty_rx_fifo[channel].ptw = 0;
    5572}
    5673
     
    6077                  unsigned int channel )   // TTY channel
    6178{
    62     // transfer character to kernel buffer and acknowledge TTY IRQ
    63     _tty_rx_buf[channel]  = _tty_get_register( channel, TTY_READ );
     79    // get pointer on TTY_RX FIFO
     80    tty_fifo_t*   fifo = &_tty_rx_fifo[channel];
    6481
    65     // flush pending memory writes
    66     asm volatile( "sync" );
     82    // get character from TTY_RX channel and acknowledge IRQ
     83    unsigned int data = _tty_get_register( channel, TTY_READ );
    6784
    68     // set kernel buffer status
    69     _tty_rx_full[channel] = 1;
     85    // transfer character to FIFO if not full
     86    // discard incoming character if full
     87    if ( fifo->sts < TTY_FIFO_DEPTH )
     88    {
     89        // store data into FIFO
     90        fifo->data[fifo->ptw] = (char)data;
    7091
    71 #if GIET_DEBUG_IRQS  // we don't take the TTY lock to avoid deadlock
    72 unsigned int gpid           = _get_procid();
    73 unsigned int cluster_xy     = gpid >> P_WIDTH;
    74 unsigned int x              = cluster_xy >> Y_WIDTH;
    75 unsigned int y              = cluster_xy & ((1<<Y_WIDTH)-1);
    76 unsigned int lpid           = gpid & ((1<<P_WIDTH)-1);
    77 _puts("\n[IRQS DEBUG] Processor[");
    78 _putd(x );
    79 _puts(",");
    80 _putd(y );
    81 _puts(",");
    82 _putd(lpid );
    83 _puts("] enters _tty_rx_isr() at cycle ");
    84 _putd(_get_proctime() );
    85 _puts("\n  read byte = ");
    86 _putx(_tty_rx_buf[channel] );
    87 _puts("\n");
    88 #endif
     92        // avoid race
     93        asm volatile( "sync" );
    8994
     95        // update FIFO state
     96        fifo->ptw = (fifo->ptw + 1) % TTY_FIFO_DEPTH;
     97        fifo->sts = fifo->sts + 1;
     98    }
     99
     100    // get owner thread indexes
     101    unsigned int trdid          = fifo->trdid;
     102    unsigned int x              = (trdid >> 24) & 0xFF;
     103    unsigned int y              = (trdid >> 16) & 0xFF;
     104    unsigned int p              = (trdid >>  8) & 0xFF;
     105    unsigned int ltid           = (trdid      ) & 0xFF;
     106
     107    // Reset NORUN_MASK_TTY bit
     108    static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
     109    unsigned int*       ptr     = &psched->context[ltid].slot[CTX_NORUN_ID];
     110    _atomic_and( ptr , ~NORUN_MASK_TTY );
    90111}
    91112
     
    95116                  unsigned int channel )   // TTY channel
    96117{
    97     _puts("\n[GIET ERROR] the _tty_tx_isr() is not implemented\n");
     118    _printf("\n[GIET ERROR] the _tty_tx_isr() is not implemented\n");
    98119    _exit();
    99120}
Note: See TracChangeset for help on using the changeset viewer.