Ignore:
Timestamp:
Mar 7, 2018, 9:02:03 AM (4 years ago)
Author:
alain
Message:

1) improve the threads and process destruction mechanism.
2) introduce FIFOs in the soclib_tty driver.

File:
1 edited

Legend:

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

    r435 r436  
    3737
    3838extern uint32_t enter_sys_read;
    39 extern uint32_t enter_devfs_move;
     39extern uint32_t enter_devfs_read;
    4040extern uint32_t enter_txt_read;
    41 extern uint32_t enter_chdev_cmd;
    42 extern uint32_t enter_chdev_server;
    43 extern uint32_t enter_tty_cmd;
    44 extern uint32_t enter_tty_isr;
    45 extern uint32_t exit_tty_isr;
    46 extern uint32_t exit_tty_cmd;
    47 extern uint32_t exit_chdev_server;
    48 extern uint32_t exit_chdev_cmd;
     41extern uint32_t enter_chdev_cmd_read;
     42extern uint32_t enter_chdev_server_read;
     43extern uint32_t enter_tty_cmd_read;
     44extern uint32_t enter_tty_isr_read;
     45extern uint32_t exit_tty_isr_read;
     46extern uint32_t exit_tty_cmd_read;
     47extern uint32_t exit_chdev_server_read;
     48extern uint32_t exit_chdev_cmd_read;
    4949extern uint32_t exit_txt_read;
    50 extern uint32_t exit_devfs_move;
     50extern uint32_t exit_devfs_read;
    5151extern uint32_t exit_sys_read;
    5252
     
    6363    reg_t        save_sr;     // required to enable IRQs during syscall
    6464
    65 #if (CONFIG_DEBUG_SYS_READ & 1)
    66 enter_sys_read = (uint32_t)tm_start;
    67 #endif
    68 
    6965        thread_t  *  this    = CURRENT_THREAD;
    7066        process_t *  process = this->process;
     
    7975#endif
    8076
     77#if (CONFIG_DEBUG_SYS_READ & 1)
     78enter_sys_read = (uint32_t)tm_start;
     79#endif
     80
    8181    // check file_id argument
    8282        if( file_id >= CONFIG_PROCESS_FILE_MAX_NR )
     
    122122
    123123    // get file descriptor cluster and local pointer
    124     vfs_file_t * file_ptr = (vfs_file_t *)GET_PTR( file_xp );
     124    vfs_file_t * file_ptr = GET_PTR( file_xp );
    125125    cxy_t        file_cxy = GET_CXY( file_xp );
    126126
     
    165165    else if( type == INODE_TYPE_DEV )  // check ownership & read from from device
    166166    {
     167        // get cluster and pointers on TXT_RX chdev
     168        xptr_t    chdev_xp  = chdev_from_file( file_xp );
     169        cxy_t     chdev_cxy = GET_CXY( chdev_xp );
     170        chdev_t * chdev_ptr = GET_PTR( chdev_xp );
     171
     172        volatile xptr_t    owner_xp;   
     173
     174        while( 1 )
     175        {
     176            // extended pointer on owner process
     177            owner_xp  = hal_remote_lwd( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) );
     178
     179            // check TXT_RX ownership
     180            if ( XPTR( local_cxy , process ) != owner_xp )
     181            {
     182                // deschedule without blocking
     183                sched_yield( "wait TXT ownership" );
     184            }
     185            else
     186            {
     187                break;
     188            }
     189        }
     190
    167191        // move count bytes from device
    168192        nbytes = devfs_user_move( true,             // from device to buffer
     
    171195                                  count );
    172196
    173         // check ownership
    174         xptr_t    chdev_xp  = chdev_from_file( file_xp );
    175         cxy_t     chdev_cxy = GET_CXY( chdev_xp );
    176         chdev_t * chdev_ptr = (chdev_t *)GET_PTR( chdev_xp );
    177         xptr_t    owner_xp  = hal_remote_lwd( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) );
    178 
    179         if( XPTR( local_cxy , process ) != owner_xp )
    180         {
    181 
    182 #if CONFIG_DEBUG_SYSCALLS_ERROR
    183 printk("\n[ERROR] in %s : process %x not in foreground for TXT%d\n",
    184 __FUNCTION__, process->pid, hal_remote_lw( XPTR(chdev_cxy,&chdev_ptr->channel) ) );
    185 #endif
    186                     this->errno = EBADFD;
    187                     return -1;
    188         }
    189197    }
    190198    else
     
    215223printk("\n[DBG] %s : thread %x exit / process %x / cycle %d\n"
    216224"nbytes = %d / first byte = %c / file_id = %d / cost = %d\n",
    217 __FUNCTION__ , local_cxy , this->core->lid , this->trdid , this->process->pid ,
     225__FUNCTION__ , this, process->pid,
    218226(uint32_t)tm_start , nbytes , *((char *)(intptr_t)paddr) , file_id ,
    219227(uint32_t)(tm_end - tm_start) );
Note: See TracChangeset for help on using the changeset viewer.