Ignore:
Timestamp:
Dec 3, 2018, 12:15:01 PM (5 years ago)
Author:
alain
Message:

Improve the FAT32 file system to support cat, rm, cp commands.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/chdev.c

    r593 r601  
    175175if( (is_rx) && (DEBUG_CHDEV_CMD_RX < rx_cycle) )
    176176printk("\n[%s] client[%x,%x] enter for RX / server[%x,%x] / cycle %d\n",
    177 __FUNCTION__, this->process->pid, this->trdid, server_ptr->process->pid, server_ptr->trdid, rx_cycle );
     177__FUNCTION__, this->process->pid, this->trdid,
     178server_ptr->process->pid, server_ptr->trdid, rx_cycle );
    178179#endif
    179180
     
    182183if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
    183184printk("\n[%s] client[%x,%x] enter for TX / server[%x,%x] / cycle %d\n",
    184 __FUNCTION__, this->process->pid, this->trdid, server_ptr->process->pid, server_ptr->trdid, tx_cycle );
     185__FUNCTION__, this->process->pid, this->trdid,
     186server_ptr->process->pid, server_ptr->trdid, tx_cycle );
    185187#endif
    186188
     
    223225if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
    224226printk("\n[%s] client thread[%x,%x] blocked\n",
    225 __FUNCTION__, this->process_pid, this->trdid );
     227__FUNCTION__, this->process->pid, this->trdid );
    226228#endif
    227229
     
    341343uint32_t rx_cycle = (uint32_t)hal_get_cycles();
    342344if( (chdev->is_rx) && (DEBUG_CHDEV_SERVER_RX < rx_cycle) )
    343 printk("\n[%s] dev_thread[%x,%x] start RX / cycle %d\n",
     345printk("\n[%s] thread[%x,%x] start RX / cycle %d\n",
    344346__FUNCTION__ , server->process->pid, server->trdid, rx_cycle );
    345347#endif
     
    348350uint32_t tx_cycle = (uint32_t)hal_get_cycles();
    349351if( (chdev->is_rx == 0) && (DEBUG_CHDEV_SERVER_TX < tx_cycle) )
    350 printk("\n[%s] dev_thread[%x,%x] start TX / cycle %d\n",
     352printk("\n[%s] thread[%x,%x] start TX / cycle %d\n",
    351353__FUNCTION__ , server->process->pid, server->trdid, tx_cycle );
    352354#endif
     355
     356        // check server thread can yield
     357        thread_assert_can_yield( server , __FUNCTION__ );
    353358
    354359        // get the lock protecting the waiting queue
     
    358363        if( xlist_is_empty( root_xp ) ) // waiting queue empty
    359364        {
     365            // release lock protecting the waiting queue
     366            remote_busylock_release( lock_xp );
    360367
    361368#if DEBUG_CHDEV_SERVER_RX
    362369rx_cycle = (uint32_t)hal_get_cycles();
    363370if( (chdev->is_rx) && (DEBUG_CHDEV_SERVER_RX < rx_cycle) )
    364 printk("\n[%s] dev_thread[%x,%x] found RX queue empty => blocks / cycle %d\n",
     371printk("\n[%s] thread[%x,%x] found RX queue empty => blocks / cycle %d\n",
    365372__FUNCTION__ , server->process->pid, server->trdid, rx_cycle );
    366373#endif
     
    369376tx_cycle = (uint32_t)hal_get_cycles();
    370377if( (chdev->is_rx == 0) && (DEBUG_CHDEV_SERVER_TX < tx_cycle) )
    371 printk("\n[%s] dev_thread[%x,%x] found TX queue empty => blocks / cycle %d\n",
     378printk("\n[%s] thread[%x,%x] found TX queue empty => blocks / cycle %d\n",
    372379__FUNCTION__ , server->process->pid, server->trdid, tx_cycle );
    373380#endif
    374 
    375             // release lock
    376             remote_busylock_release( lock_xp );
    377 
    378381            // block
    379382            thread_block( XPTR( local_cxy , server ) , THREAD_BLOCKED_IDLE );
    380 
    381 // check server thread can yield
    382 assert( (server->busylocks == 0),
    383 "cannot yield : busylocks = %d\n", server->busylocks );
    384383
    385384            // deschedule
     
    388387        else                            // waiting queue not empty
    389388        {
     389            // release lock protecting the waiting queue
     390            remote_busylock_release( lock_xp );
     391
    390392            // get extended pointer on first client thread
    391393            client_xp = XLIST_FIRST( root_xp , thread_t , wait_list );
     
    395397            client_ptr = GET_PTR( client_xp );
    396398
    397             // remove this first client thread from waiting queue
    398             xlist_unlink( XPTR( client_cxy , &client_ptr->wait_list ) );
    399 
    400             // release lock
    401             remote_busylock_release( lock_xp );
     399#if( DDEBUG_CHDEV_SERVER_TX || DEBUG_CHDEV_SERVER_RX )
     400process_t * process      = hal_remote_lpt( XPTR( client_cxy , &client_ptr->process ) );
     401pid_t       client_pid   = hal_remote_l32( XPTR( client_cxy , &process->pid ) );
     402process_t   client_trdid = hal_remote_l32( XPTR( client_cxy , &client_ptr->trdid ) );
     403#endif
    402404
    403405#if DEBUG_CHDEV_SERVER_RX
    404406rx_cycle = (uint32_t)hal_get_cycles();
    405407if( (chdev->is_rx) && (DEBUG_CHDEV_SERVER_RX < rx_cycle) )
    406 printk("\n[%s] dev_thread[%x,%x] for RX get client thread[%x,%x] / cycle %d\n",
    407 __FUNCTION__, server->process->pid, server->trdid,
    408 client_ptr->process->pid, client_ptr->trdid, rx_cycle );
     408printk("\n[%s] thread[%x,%x] for RX get client thread[%x,%x] / cycle %d\n",
     409__FUNCTION__, server->process->pid, server->trdid, client_pid, client_trdid, cycle );
    409410#endif
    410411
     
    412413tx_cycle = (uint32_t)hal_get_cycles();
    413414if( (chdev->is_rx == 0) && (DEBUG_CHDEV_SERVER_TX < tx_cycle) )
    414 printk("\n[%s] dev_thread[%x,%x] for TX get client thread[%x,%x] / cycle %d\n",
    415 __FUNCTION__, server->process->pid, server->trdid,
    416 client_ptr->process->pid, client_ptr->trdid, tx_cycle );
     415printk("\n[%s] thread[%x,%x] for TX get client thread[%x,%x] / cycle %d\n",
     416__FUNCTION__, server->process->pid, server->trdid, client_pid, client_trdid, cycle );
    417417#endif
    418418
     
    425425#endif
    426426
    427             // call driver command function to execute I/O operation
     427            // call the (blocking) driver command function
     428            // to launch I/O operation AND wait completion
    428429            chdev->cmd( client_xp );
    429430       
    430             // unblock client thread
     431            // unblock client thread when driver returns
    431432            thread_unblock( client_xp , THREAD_BLOCKED_IO );
     433
     434            // get the lock protecting the waiting queue
     435            remote_busylock_acquire( lock_xp );
     436
     437            // remove this client thread from chdev waiting queue
     438            xlist_unlink( XPTR( client_cxy , &client_ptr->wait_list ) );
     439
     440            // release lock protecting the waiting queue
     441            remote_busylock_release( lock_xp );
    432442
    433443#if DEBUG_CHDEV_SERVER_RX
    434444rx_cycle = (uint32_t)hal_get_cycles();
    435445if( (chdev->is_rx) && (DEBUG_CHDEV_SERVER_RX < rx_cycle) )
    436 printk("\n[%s] dev_thread[%x,%x] completes RX for client thread[%x,%x] / cycle %d\n",
    437 __FUNCTION__, server->process->pid, server->trdid,
    438 client_ptr->process->pid, client_ptr->trdid, rx_cycle );
     446printk("\n[%s] thread[%x,%x] completes RX for client thread[%x,%x] / cycle %d\n",
     447__FUNCTION__, server->process->pid, server->trdid, client_pid, client_trdid, cycle );
    439448#endif
    440449
     
    442451tx_cycle = (uint32_t)hal_get_cycles();
    443452if( (chdev->is_rx == 0) && (DEBUG_CHDEV_SERVER_TX < tx_cycle) )
    444 printk("\n[%s] dev_thread[%x,%x] completes TX for client thread[%x,%x] / cycle %d\n",
    445 __FUNCTION__, server->process->pid, server->trdid,
    446 client_ptr->process->pid, client_ptr->trdid, tx_cycle );
     453printk("\n[%s] thread[%x,%x] completes TX for client thread[%x,%x] / cycle %d\n",
     454__FUNCTION__, server->process->pid, server->trdid, client_pid, client_trdid, cycle );
    447455#endif
    448456
     
    633641                        pid        = hal_remote_l32 ( XPTR( thread_cxy , &process->pid        ) );
    634642
    635             nolock_printk("- thread %X / cluster %X / trdid %X / pid %X\n",
    636             thread_ptr, thread_cxy, trdid, pid );
     643            nolock_printk("- thread[%x,%x]\n", pid, trdid );
    637644        }
    638645    }
Note: See TracChangeset for help on using the changeset viewer.