Ignore:
Timestamp:
Oct 4, 2018, 11:50:21 PM (6 years ago)
Author:
alain
Message:

Complete restructuration of kernel locks.

File:
1 edited

Legend:

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

    r506 r566  
    2525#include <hal_uspace.h>
    2626#include <hal_irqmask.h>
     27#include <remote_queuelock.h>
    2728#include <core.h>
    2829#include <thread.h>
     
    9596    xptr_t children_lock_xp = XPTR( owner_cxy , &process->children_lock );
    9697
    97     // exit this blocking loop only when a child processes change state
     98    // exit this loop only when a child processes change state
    9899    while( 1 )
    99100    {
     
    102103 
    103104        // get lock protecting children list
    104         remote_spinlock_lock( children_lock_xp );
     105        remote_queuelock_acquire( children_lock_xp );
    105106
    106107        // scan the list of child process
     
    113114
    114115            // get PID, term_state, and main thread from child process
    115             child_pid    = hal_remote_lw (XPTR( child_cxy , &child_ptr->pid ));
    116             child_state  = hal_remote_lw ( XPTR(child_cxy , &child_ptr->term_state ) );
     116            child_pid    = hal_remote_l32 (XPTR( child_cxy , &child_ptr->pid ));
     117            child_state  = hal_remote_l32 ( XPTR(child_cxy , &child_ptr->term_state ) );
    117118            child_thread = hal_remote_lpt(XPTR( child_cxy , &child_ptr->th_tbl[0] ));
    118119
    119 #if (DEBUG_SYS_WAIT &1)
     120#if (DEBUG_SYS_WAIT & 1)
    120121cycle = hal_get_cycles();
    121122if( DEBUG_SYS_WAIT < cycle )
     
    130131                 ((child_state & PROCESS_TERM_WAIT) == 0) )
    131132            {
    132                 // set the PROCESS_FLAG_WAIT in child process descriptor
     133                // set the PROCESS_TERM_WAIT in child process descriptor
    133134                hal_remote_atomic_or( XPTR( child_cxy , &child_ptr->term_state ),
    134135                                      PROCESS_TERM_WAIT );
     
    140141
    141142                // release lock protecting children list
    142                 remote_spinlock_unlock( children_lock_xp );
     143                remote_queuelock_release( children_lock_xp );
    143144
    144145#if DEBUG_SYS_WAIT
     
    163164        }  // end loop on children
    164165       
     166        // we execute this code when no child terminated:
     167        // - release the lock protecting children list,
     168        // - block on the WAIT condition
     169        // - deschedule to keep waiting in the while loop
     170
     171        // release lock protecting children list
     172        remote_queuelock_release( children_lock_xp );
     173
    165174        // block on WAIT condition
    166175        thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_WAIT );
    167 
    168         // release lock protecting children list
    169         remote_spinlock_unlock( children_lock_xp );
    170176
    171177#if (DEBUG_SYS_WAIT & 1)
Note: See TracChangeset for help on using the changeset viewer.