source: src/libcfa/concurrency/kernel@ 27cc24e

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 27cc24e was 9c31349, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Removed unnecessary synchronisation routines in threads, now using monitor instead

  • Property mode set to 100644
File size: 2.0 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
30void lock( spinlock * );
31void unlock( spinlock * );
32
33struct signal_once {
34 volatile bool condition;
35 struct spinlock lock;
36 struct simple_thread_list blocked;
37};
38
39void ?{}(signal_once * this);
40void ^?{}(signal_once * this);
41
42void wait( signal_once * );
43void signal( signal_once * );
44
45//-----------------------------------------------------------------------------
46// Cluster
47struct cluster {
48 simple_thread_list ready_queue;
49 spinlock lock;
50};
51
52void ?{}(cluster * this);
53void ^?{}(cluster * this);
54
55//-----------------------------------------------------------------------------
56// Processor
57enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule };
58struct FinishAction {
59 FinishOpCode action_code;
60 thread_desc * thrd;
61 spinlock * lock;
62};
63static inline void ?{}(FinishAction * this) {
64 this->action_code = No_Action;
65 this->thrd = NULL;
66 this->lock = NULL;
67}
68static inline void ^?{}(FinishAction * this) {}
69
70struct processor {
71 struct processorCtx_t * runner;
72 cluster * cltr;
73 coroutine_desc * current_coroutine;
74 thread_desc * current_thread;
75 pthread_t kernel_thread;
76
77 signal_once terminated;
78 volatile bool is_terminated;
79
80 struct FinishAction finish;
81};
82
83void ?{}(processor * this);
84void ?{}(processor * this, cluster * cltr);
85void ^?{}(processor * this);
86
87#endif //KERNEL_H
88
89// Local Variables: //
90// mode: c //
91// tab-width: 4 //
92// End: //
Note: See TracBrowser for help on using the repository browser.