source: src/libcfa/concurrency/kernel @ 6e09f211

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 6e09f211 was c81ebf9, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

More work done on preemption in cforall, next step disabling interrupts at the correct places

  • Property mode set to 100644
File size: 2.3 KB
Line 
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//
8// kernel --
9//
10// Author           : Thierry Delisle
11// Created On       : Tue Jan 17 12:27:26 2017
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
20#include <stdbool.h>
21
22#include "invoke.h"
23
24extern "C" {
25#include <pthread.h>
26}
27
28//-----------------------------------------------------------------------------
29// Locks
30bool try_lock( spinlock * );
31void lock( spinlock * );
32void unlock( spinlock * );
33
34struct signal_once {
35        volatile bool cond;
36        struct spinlock lock;
37        struct __thread_queue_t blocked;
38};
39
40void ?{}(signal_once * this);
41void ^?{}(signal_once * this);
42
43void wait( signal_once * );
44void signal( signal_once * );
45
46//-----------------------------------------------------------------------------
47// Cluster
48struct cluster {
49        __thread_queue_t ready_queue;
50        spinlock lock;
51};
52
53void ?{}(cluster * this);
54void ^?{}(cluster * this);
55
56//-----------------------------------------------------------------------------
57// Processor
58enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule };
59
60//TODO use union, many of these fields are mutually exclusive (i.e. MULTI vs NOMULTI)
61struct FinishAction {
62        FinishOpCode action_code;
63        thread_desc * thrd;
64        spinlock * lock;
65        spinlock ** locks;
66        unsigned short lock_count;
67        thread_desc ** thrds;
68        unsigned short thrd_count;
69};
70static inline void ?{}(FinishAction * this) {
71        this->action_code = No_Action;
72        this->thrd = NULL;
73        this->lock = NULL;
74}
75static inline void ^?{}(FinishAction * this) {}
76
77struct processor {
78        struct processorCtx_t * runner;
79        cluster * cltr;
80        coroutine_desc * current_coroutine;
81        thread_desc * current_thread;
82        pthread_t kernel_thread;
83       
84        signal_once terminated;
85        volatile bool is_terminated;
86
87        struct FinishAction finish;
88
89        struct alarm_node_t * preemption_alarm;
90        unsigned int preemption;
91
92        unsigned short disable_preempt_count;
93
94        bool pending_preemption;
95};
96
97void ?{}(processor * this);
98void ?{}(processor * this, cluster * cltr);
99void ^?{}(processor * this);
100
101#endif //KERNEL_H
102
103// Local Variables: //
104// mode: CFA //
105// tab-width: 6 //
106// End: //
Note: See TracBrowser for help on using the repository browser.