Changeset 657 for trunk/kernel/kern/chdev.c
- Timestamp:
- Mar 18, 2020, 11:16:59 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/chdev.c
r635 r657 1 1 /* 2 * chdev.c - channel device descriptor operationsimplementation.2 * chdev.c - channel device API implementation. 3 3 * 4 * Authors Alain Greiner (2016 )4 * Authors Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 148 148 #endif 149 149 150 thread_t * this = CURRENT_THREAD; 150 thread_t * this = CURRENT_THREAD; 151 xptr_t client_xp = XPTR( local_cxy , this ); 151 152 152 153 // get chdev cluster and local pointer … … 197 198 lock_xp = XPTR( chdev_cxy , &chdev_ptr->wait_lock ); 198 199 199 // The following actions executein critical section,200 // because the lock_acquire / lock_release :201 // (1) take the lock protecting the chdev state200 // The following actions are executed in critical section, 201 // (because the busylock_acquire / busylock_release) 202 // (1) take the lock protecting the waiting queue 202 203 // (2) register client thread in server queue 203 204 // (3) unblock the server thread and block client thread … … 224 225 225 226 // 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 ); 228 229 229 230 #if (DEBUG_CHDEV_CMD_TX & 1) … … 300 301 server = CURRENT_THREAD; 301 302 302 // build extended pointer on root of client threads queue303 // build extended pointer on root & lock of client threads queue 303 304 root_xp = XPTR( local_cxy , &chdev->wait_root ); 304 305 // build extended pointer on lock protecting client threads queue306 305 lock_xp = XPTR( local_cxy , &chdev->wait_lock ); 307 306 … … 351 350 #endif 352 351 // block 353 thread_block( XPTR( local_cxy , server ) , THREAD_BLOCKED_ IDLE);352 thread_block( XPTR( local_cxy , server ) , THREAD_BLOCKED_CLIENT ); 354 353 355 354 // deschedule … … 358 357 else // waiting queue not empty 359 358 { 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 360 367 // release lock protecting the waiting queue 361 368 remote_busylock_release( lock_xp ); 362 363 // get extended pointer on first client thread364 client_xp = XLIST_FIRST( root_xp , thread_t , wait_list );365 366 // get client thread cluster and local pointer367 client_cxy = GET_CXY( client_xp );368 client_ptr = GET_PTR( client_xp );369 369 370 370 #if( DEBUG_CHDEV_SERVER_TX || DEBUG_CHDEV_SERVER_RX ) … … 402 402 // unblock client thread when driver returns 403 403 thread_unblock( client_xp , THREAD_BLOCKED_IO ); 404 405 // get the lock protecting the waiting queue406 remote_busylock_acquire( lock_xp );407 408 // remove this client thread from chdev waiting queue409 xlist_unlink( XPTR( client_cxy , &client_ptr->wait_list ) );410 411 // release lock protecting the waiting queue412 remote_busylock_release( lock_xp );413 404 414 405 #if DEBUG_CHDEV_SERVER_RX
Note: See TracChangeset
for help on using the changeset viewer.