Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/kernel

    r6b0b624 rbdeba0b  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    910// Author           : Thierry Delisle
    1011// Created On       : Tue Jan 17 12:27:26 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:58:39 2017
    13 // Update Count     : 2
     12// Last Modified By : Thierry Delisle
     13// Last Modified On : --
     14// Update Count     : 0
    1415//
    1516
    16 #pragma once
     17#ifndef KERNEL_H
     18#define KERNEL_H
    1719
    1820#include <stdbool.h>
     
    2628//-----------------------------------------------------------------------------
    2729// Locks
    28 void lock      ( spinlock * DEBUG_CTX_PARAM2 );       // Lock the spinlock, spin if already acquired
    29 void lock_yield( spinlock * DEBUG_CTX_PARAM2 );       // Lock the spinlock, yield repeatedly if already acquired
    30 bool try_lock  ( spinlock * DEBUG_CTX_PARAM2 );       // Lock the spinlock, return false if already acquired
    31 void unlock    ( spinlock * );                        // Unlock the spinlock
     30bool try_lock  ( spinlock * DEBUG_CTX_PARAM2 );
     31void lock      ( spinlock * DEBUG_CTX_PARAM2 );
     32void lock_yield( spinlock * DEBUG_CTX_PARAM2 );
     33void unlock    ( spinlock * );
    3234
    3335struct semaphore {
     
    4648// Cluster
    4749struct cluster {
    48         spinlock ready_queue_lock;                      // Ready queue locks
    49         __thread_queue_t ready_queue;                   // Ready queue for threads
    50         unsigned long long int preemption;              // Preemption rate on this cluster
     50        __thread_queue_t ready_queue;
     51        spinlock lock;
    5152};
    5253
     
    7576static inline void ^?{}(FinishAction * this) {}
    7677
    77 // Processor
    78 // Wrapper around kernel threads
    7978struct processor {
    80         // Main state
    81         struct processorCtx_t * runner;                 // Coroutine ctx who does keeps the state of the processor
    82         cluster * cltr;                                 // Cluster from which to get threads
    83         pthread_t kernel_thread;                        // Handle to pthreads
     79        struct processorCtx_t * runner;
     80        cluster * cltr;
     81        pthread_t kernel_thread;
    8482
    85         // Termination
    86         volatile bool do_terminate;                     // Set to true to notify the processor should terminate
    87         semaphore terminated;                           // Termination synchronisation
     83        semaphore terminated;
     84        volatile bool is_terminated;
    8885
    89         // RunThread data
    90         struct FinishAction finish;                     // Action to do after a thread is ran
     86        struct FinishAction finish;
    9187
    92         // Preemption data
    93         struct alarm_node_t * preemption_alarm;         // Node which is added in the discrete event simulaiton
    94         bool pending_preemption;                        // If true, a preemption was triggered in an unsafe region, the processor must preempt as soon as possible
     88        struct alarm_node_t * preemption_alarm;
     89        unsigned int preemption;
    9590
    96 #ifdef __CFA_DEBUG__
    97         char * last_enable;                             // Last function to enable preemption on this processor
    98 #endif
     91        bool pending_preemption;
     92
     93        char * last_enable;
    9994};
    10095
     
    10398void ^?{}(processor * this);
    10499
     100#endif //KERNEL_H
     101
    105102// Local Variables: //
    106 // mode: c //
    107 // tab-width: 4 //
     103// mode: CFA //
     104// tab-width: 6 //
    108105// End: //
Note: See TracChangeset for help on using the changeset viewer.