source: src/libcfa/concurrency/kernel @ b227f68

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since b227f68 was b227f68, checked in by Thierry Delisle <tdelisle@…>, 4 years ago

Commented some debug messages.
Monitors now yield when spinning.
Debug mode saves more information about previous locks and interrupts

  • 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 * DEBUG_CTX_PARAM2 );
31void lock      ( spinlock * DEBUG_CTX_PARAM2 );
32void lock_yield( spinlock * DEBUG_CTX_PARAM2 );
33void unlock    ( spinlock * );
34
35struct signal_once {
36        volatile bool cond;
37        struct spinlock lock;
38        struct __thread_queue_t blocked;
39};
40
41void ?{}(signal_once * this);
42void ^?{}(signal_once * this);
43
44void wait( signal_once * );
45void signal( signal_once * );
46
47//-----------------------------------------------------------------------------
48// Cluster
49struct cluster {
50        __thread_queue_t ready_queue;
51        spinlock lock;
52};
53
54void ?{}(cluster * this);
55void ^?{}(cluster * this);
56
57//-----------------------------------------------------------------------------
58// Processor
59enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule };
60
61//TODO use union, many of these fields are mutually exclusive (i.e. MULTI vs NOMULTI)
62struct FinishAction {
63        FinishOpCode action_code;
64        thread_desc * thrd;
65        spinlock * lock;
66        spinlock ** locks;
67        unsigned short lock_count;
68        thread_desc ** thrds;
69        unsigned short thrd_count;
70};
71static inline void ?{}(FinishAction * this) {
72        this->action_code = No_Action;
73        this->thrd = NULL;
74        this->lock = NULL;
75}
76static inline void ^?{}(FinishAction * this) {}
77
78struct processor {
79        struct processorCtx_t * runner;
80        cluster * cltr;
81        pthread_t kernel_thread;
82
83        signal_once terminated;
84        volatile bool is_terminated;
85
86        struct FinishAction finish;
87
88        struct alarm_node_t * preemption_alarm;
89        unsigned int preemption;
90
91        bool pending_preemption;
92
93        char * last_enable;
94};
95
96void ?{}(processor * this);
97void ?{}(processor * this, cluster * cltr);
98void ^?{}(processor * this);
99
100#endif //KERNEL_H
101
102// Local Variables: //
103// mode: CFA //
104// tab-width: 6 //
105// End: //
Note: See TracBrowser for help on using the repository browser.