Ignore:
Timestamp:
Aug 14, 2017, 2:03:39 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
74b007ba
Parents:
fd344aa (diff), 54cd58b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/kernel

    rfd344aa r9236060  
    1 //                              -*- Mode: CFA -*-
    21//
    32// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    109// Author           : Thierry Delisle
    1110// Created On       : Tue Jan 17 12:27:26 2017
    12 // Last Modified By : Thierry Delisle
    13 // Last Modified On : --
    14 // Update Count     : 0
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sat Jul 22 09:58:39 2017
     13// Update Count     : 2
    1514//
    1615
    17 #ifndef KERNEL_H
    18 #define KERNEL_H
     16#pragma once
    1917
    2018#include <stdbool.h>
     
    2826//-----------------------------------------------------------------------------
    2927// Locks
    30 bool try_lock  ( spinlock * DEBUG_CTX_PARAM2 );
    31 void lock      ( spinlock * DEBUG_CTX_PARAM2 );
    32 void lock_yield( spinlock * DEBUG_CTX_PARAM2 );
    33 void unlock    ( spinlock * );
     28void lock      ( spinlock * DEBUG_CTX_PARAM2 );       // Lock the spinlock, spin if already acquired
     29void lock_yield( spinlock * DEBUG_CTX_PARAM2 );       // Lock the spinlock, yield repeatedly if already acquired
     30bool try_lock  ( spinlock * DEBUG_CTX_PARAM2 );       // Lock the spinlock, return false if already acquired
     31void unlock    ( spinlock * );                        // Unlock the spinlock
    3432
    3533struct semaphore {
     
    4846// Cluster
    4947struct cluster {
    50         __thread_queue_t ready_queue;
    51         spinlock lock;
     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
    5251};
    5352
     
    7675static inline void ^?{}(FinishAction & this) {}
    7776
     77// Processor
     78// Wrapper around kernel threads
    7879struct processor {
    79         struct processorCtx_t * runner;
    80         cluster * cltr;
    81         pthread_t kernel_thread;
     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
    8284
    83         semaphore terminated;
    84         volatile bool is_terminated;
     85        // Termination
     86        volatile bool do_terminate;                     // Set to true to notify the processor should terminate
     87        semaphore terminated;                           // Termination synchronisation
    8588
    86         struct FinishAction finish;
     89        // RunThread data
     90        struct FinishAction finish;                     // Action to do after a thread is ran
    8791
    88         struct alarm_node_t * preemption_alarm;
    89         unsigned int preemption;
     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
    9095
    91         bool pending_preemption;
    92 
    93         char * last_enable;
     96#ifdef __CFA_DEBUG__
     97        char * last_enable;                             // Last function to enable preemption on this processor
     98#endif
    9499};
    95100
     
    98103void ^?{}(processor & this);
    99104
    100 #endif //KERNEL_H
    101 
    102105// Local Variables: //
    103 // mode: CFA //
    104 // tab-width: 6 //
     106// mode: c //
     107// tab-width: 4 //
    105108// End: //
Note: See TracChangeset for help on using the changeset viewer.