Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel_private.hfa

    re873838 re235429  
    3333}
    3434
    35 void __schedule_thread( $thread * )
     35void __schedule_thread( struct __processor_id_t *, $thread * )
    3636#if defined(NDEBUG) || (!defined(__CFA_DEBUG__) && !defined(__CFA_VERIFY__))
    37         __attribute__((nonnull (1)))
     37        __attribute__((nonnull (2)))
    3838#endif
    3939;
    4040
    41 //release/wake-up the following resources
    42 void __thread_finish( $thread * thrd );
     41//Block current thread and release/wake-up the following resources
     42void __leave_thread() __attribute__((noreturn));
    4343
    4444//-----------------------------------------------------------------------------
     
    6363)
    6464
    65 #define TICKET_BLOCKED (-1) // thread is blocked
    66 #define TICKET_RUNNING ( 0) // thread is running
    67 #define TICKET_UNBLOCK ( 1) // thread should ignore next block
     65// KERNEL ONLY unpark with out disabling interrupts
     66void __unpark( struct __processor_id_t *, $thread * thrd );
     67
     68static inline bool __post(single_sem & this, struct __processor_id_t * id) {
     69        for() {
     70                struct $thread * expected = this.ptr;
     71                if(expected == 1p) return false;
     72                if(expected == 0p) {
     73                        if(__atomic_compare_exchange_n(&this.ptr, &expected, 1p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
     74                                return false;
     75                        }
     76                }
     77                else {
     78                        if(__atomic_compare_exchange_n(&this.ptr, &expected, 0p, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {
     79                                __unpark( id, expected );
     80                                return true;
     81                        }
     82                }
     83        }
     84}
    6885
    6986//-----------------------------------------------------------------------------
     
    180197// Reader side : acquire when using the ready queue to schedule but not
    181198//  creating/destroying queues
    182 static inline void ready_schedule_lock(void) with(*__scheduler_lock) {
    183         /*paranoid*/ verify( kernelTLS.this_proc_id );
    184 
    185         unsigned iproc = kernelTLS.this_proc_id->id;
    186         /*paranoid*/ verify(data[iproc].handle == kernelTLS.this_proc_id);
     199static inline void ready_schedule_lock( struct __processor_id_t * proc) with(*__scheduler_lock) {
     200        unsigned iproc = proc->id;
     201        /*paranoid*/ verify(data[iproc].handle == proc);
    187202        /*paranoid*/ verify(iproc < ready);
    188203
     
    206221}
    207222
    208 static inline void ready_schedule_unlock(void) with(*__scheduler_lock) {
    209         /*paranoid*/ verify( kernelTLS.this_proc_id );
    210 
    211         unsigned iproc = kernelTLS.this_proc_id->id;
    212         /*paranoid*/ verify(data[iproc].handle == kernelTLS.this_proc_id);
     223static inline void ready_schedule_unlock( struct __processor_id_t * proc) with(*__scheduler_lock) {
     224        unsigned iproc = proc->id;
     225        /*paranoid*/ verify(data[iproc].handle == proc);
    213226        /*paranoid*/ verify(iproc < ready);
    214227        /*paranoid*/ verify(data[iproc].lock);
     
    222235
    223236#ifdef __CFA_WITH_VERIFY__
    224         static inline bool ready_schedule_islocked(void) {
    225                 /*paranoid*/ verify( kernelTLS.this_proc_id );
    226                 __processor_id_t * proc = kernelTLS.this_proc_id;
     237        static inline bool ready_schedule_islocked( struct __processor_id_t * proc) {
    227238                return __scheduler_lock->data[proc->id].owned;
    228239        }
Note: See TracChangeset for help on using the changeset viewer.