source: src/libcfa/concurrency/kernel @ 1c273d0

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 1c273d0 was 1c273d0, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

preemption works for threads

  • Property mode set to 100644
File size: 2.4 KB
RevLine 
[8118303]1//                              -*- Mode: CFA -*-
2//
3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
4//
5// The contents of this file are covered under the licence agreement in the
6// file "LICENCE" distributed with Cforall.
7//
[75a17f1]8// kernel --
[8118303]9//
10// Author           : Thierry Delisle
[75f3522]11// Created On       : Tue Jan 17 12:27:26 2017
[8118303]12// Last Modified By : Thierry Delisle
13// Last Modified On : --
14// Update Count     : 0
15//
16
17#ifndef KERNEL_H
18#define KERNEL_H
19
[c84e80a]20#include <stdbool.h>
[8118303]21
[bd98b58]22#include "invoke.h"
23
[8def349]24extern "C" {
25#include <pthread.h>
26}
27
[db6f06a]28//-----------------------------------------------------------------------------
29// Locks
[1c273d0]30bool try_lock( spinlock *
31        #ifdef __CFA_DEBUG__
32                , const char * caller
33        #endif
34);
35
36void lock( spinlock *
37        #ifdef __CFA_DEBUG__
38                , const char * caller
39        #endif
40);
41
[db6f06a]42void unlock( spinlock * );
43
[9c31349]44struct signal_once {
[5ea06d6]45        volatile bool cond;
[9c31349]46        struct spinlock lock;
[5ea06d6]47        struct __thread_queue_t blocked;
[9c31349]48};
49
50void ?{}(signal_once * this);
51void ^?{}(signal_once * this);
52
[db6f06a]53void wait( signal_once * );
54void signal( signal_once * );
55
[bd98b58]56//-----------------------------------------------------------------------------
57// Cluster
58struct cluster {
[5ea06d6]59        __thread_queue_t ready_queue;
[db6f06a]60        spinlock lock;
[bd98b58]61};
62
63void ?{}(cluster * this);
64void ^?{}(cluster * this);
65
66//-----------------------------------------------------------------------------
67// Processor
[0c78741]68enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule };
69
70//TODO use union, many of these fields are mutually exclusive (i.e. MULTI vs NOMULTI)
[db6f06a]71struct FinishAction {
72        FinishOpCode action_code;
[348006f]73        thread_desc * thrd;
[db6f06a]74        spinlock * lock;
[0c78741]75        spinlock ** locks;
76        unsigned short lock_count;
77        thread_desc ** thrds;
78        unsigned short thrd_count;
[8fcbb4c]79};
[db6f06a]80static inline void ?{}(FinishAction * this) {
81        this->action_code = No_Action;
82        this->thrd = NULL;
83        this->lock = NULL;
84}
85static inline void ^?{}(FinishAction * this) {}
[8fcbb4c]86
[c84e80a]87struct processor {
[8fcbb4c]88        struct processorCtx_t * runner;
[bd98b58]89        cluster * cltr;
[8def349]90        pthread_t kernel_thread;
[db6f06a]91       
92        signal_once terminated;
93        volatile bool is_terminated;
94
95        struct FinishAction finish;
[c81ebf9]96
97        struct alarm_node_t * preemption_alarm;
98        unsigned int preemption;
99
100        bool pending_preemption;
[4e6fb8e]101
102        char * last_enable;
[c84e80a]103};
104
[8def349]105void ?{}(processor * this);
[bd98b58]106void ?{}(processor * this, cluster * cltr);
[c84e80a]107void ^?{}(processor * this);
108
[8118303]109#endif //KERNEL_H
110
111// Local Variables: //
[fa21ac9]112// mode: CFA //
113// tab-width: 6 //
[8118303]114// End: //
Note: See TracBrowser for help on using the repository browser.