source: src/libcfa/concurrency/kernel@ 0428aad

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 0428aad was 0c78741, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Implementation of internal scheduling in CFA

  • Property mode set to 100644
File size: 2.2 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
30void lock( spinlock * );
31void unlock( spinlock * );
32
[9c31349]33struct signal_once {
[5ea06d6]34 volatile bool cond;
[9c31349]35 struct spinlock lock;
[5ea06d6]36 struct __thread_queue_t blocked;
[9c31349]37};
38
39void ?{}(signal_once * this);
40void ^?{}(signal_once * this);
41
[db6f06a]42void wait( signal_once * );
43void signal( signal_once * );
44
[bd98b58]45//-----------------------------------------------------------------------------
46// Cluster
47struct cluster {
[5ea06d6]48 __thread_queue_t ready_queue;
[db6f06a]49 spinlock lock;
[bd98b58]50};
51
52void ?{}(cluster * this);
53void ^?{}(cluster * this);
54
55//-----------------------------------------------------------------------------
56// Processor
[0c78741]57enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule };
58
59//TODO use union, many of these fields are mutually exclusive (i.e. MULTI vs NOMULTI)
[db6f06a]60struct FinishAction {
61 FinishOpCode action_code;
[348006f]62 thread_desc * thrd;
[db6f06a]63 spinlock * lock;
[0c78741]64 spinlock ** locks;
65 unsigned short lock_count;
66 thread_desc ** thrds;
67 unsigned short thrd_count;
[8fcbb4c]68};
[db6f06a]69static inline void ?{}(FinishAction * this) {
70 this->action_code = No_Action;
71 this->thrd = NULL;
72 this->lock = NULL;
73}
74static inline void ^?{}(FinishAction * this) {}
[8fcbb4c]75
[c84e80a]76struct processor {
[8fcbb4c]77 struct processorCtx_t * runner;
[bd98b58]78 cluster * cltr;
[c3acb841]79 coroutine_desc * current_coroutine;
[348006f]80 thread_desc * current_thread;
[8def349]81 pthread_t kernel_thread;
[db6f06a]82
83 signal_once terminated;
84 volatile bool is_terminated;
85
86 struct FinishAction finish;
[c84e80a]87};
88
[8def349]89void ?{}(processor * this);
[bd98b58]90void ?{}(processor * this, cluster * cltr);
[c84e80a]91void ^?{}(processor * this);
92
[8118303]93#endif //KERNEL_H
94
95// Local Variables: //
96// mode: c //
97// tab-width: 4 //
98// End: //
Note: See TracBrowser for help on using the repository browser.