Ignore:
Timestamp:
Mar 18, 2020, 11:16:59 PM (4 years ago)
Author:
alain
Message:

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

File:
1 edited

Legend:

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

    r635 r657  
    11/*
    2  * chdev.c - channel device descriptor operations implementation.
     2 * chdev.c - channel device API implementation.
    33 *
    4  * Authors  Alain Greiner   (2016)
     4 * Authors  Alain Greiner   (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    148148#endif
    149149
    150     thread_t * this = CURRENT_THREAD;
     150    thread_t * this      = CURRENT_THREAD;
     151    xptr_t     client_xp = XPTR( local_cxy , this );
    151152
    152153    // get chdev cluster and local pointer
     
    197198    lock_xp            = XPTR( chdev_cxy , &chdev_ptr->wait_lock );
    198199
    199     // The following actions execute in critical section,
    200     // because the lock_acquire / lock_release :
    201     // (1) take the lock protecting the chdev state
     200    // The following actions are executed in critical section,
     201    // (because the busylock_acquire / busylock_release)
     202    // (1) take the lock protecting the waiting queue
    202203    // (2) register client thread in server queue
    203204    // (3) unblock the server thread and block client thread
     
    224225 
    225226    // 3. client thread unblocks server thread and blocks itself
    226     thread_unblock( server_xp , THREAD_BLOCKED_IDLE );
    227     thread_block( XPTR( local_cxy , CURRENT_THREAD ) , THREAD_BLOCKED_IO );
     227    thread_unblock( server_xp , THREAD_BLOCKED_CLIENT );
     228    thread_block( client_xp , THREAD_BLOCKED_IO );
    228229
    229230#if (DEBUG_CHDEV_CMD_TX & 1)
     
    300301    server = CURRENT_THREAD;
    301302
    302     // build extended pointer on root of client threads queue
     303    // build extended pointer on root & lock of client threads queue
    303304    root_xp = XPTR( local_cxy , &chdev->wait_root );
    304 
    305     // build extended pointer on lock protecting client threads queue
    306305    lock_xp = XPTR( local_cxy , &chdev->wait_lock );
    307306
     
    351350#endif
    352351            // block
    353             thread_block( XPTR( local_cxy , server ) , THREAD_BLOCKED_IDLE );
     352            thread_block( XPTR( local_cxy , server ) , THREAD_BLOCKED_CLIENT );
    354353
    355354            // deschedule
     
    358357        else                            // waiting queue not empty
    359358        {
     359            // get pointers on first client thread
     360            client_xp  = XLIST_FIRST( root_xp , thread_t , wait_list );
     361            client_cxy = GET_CXY( client_xp );
     362            client_ptr = GET_PTR( client_xp );
     363
     364            // remove this client thread from chdev waiting queue
     365            xlist_unlink( XPTR( client_cxy , &client_ptr->wait_list ) );
     366
    360367            // release lock protecting the waiting queue
    361368            remote_busylock_release( lock_xp );
    362 
    363             // get extended pointer on first client thread
    364             client_xp = XLIST_FIRST( root_xp , thread_t , wait_list );
    365 
    366             // get client thread cluster and local pointer
    367             client_cxy = GET_CXY( client_xp );
    368             client_ptr = GET_PTR( client_xp );
    369369
    370370#if( DEBUG_CHDEV_SERVER_TX || DEBUG_CHDEV_SERVER_RX )
     
    402402            // unblock client thread when driver returns
    403403            thread_unblock( client_xp , THREAD_BLOCKED_IO );
    404 
    405             // get the lock protecting the waiting queue
    406             remote_busylock_acquire( lock_xp );
    407 
    408             // remove this client thread from chdev waiting queue
    409             xlist_unlink( XPTR( client_cxy , &client_ptr->wait_list ) );
    410 
    411             // release lock protecting the waiting queue
    412             remote_busylock_release( lock_xp );
    413404
    414405#if DEBUG_CHDEV_SERVER_RX
Note: See TracChangeset for help on using the changeset viewer.