source: src/libcfa/concurrency/kernel@ c81ebf9

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 c81ebf9 was c81ebf9, checked in by Thierry Delisle <tdelisle@…>, 8 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
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
[c81ebf9]30bool try_lock( spinlock * );
[db6f06a]31void lock( spinlock * );
32void unlock( spinlock * );
33
[9c31349]34struct signal_once {
[5ea06d6]35 volatile bool cond;
[9c31349]36 struct spinlock lock;
[5ea06d6]37 struct __thread_queue_t blocked;
[9c31349]38};
39
40void ?{}(signal_once * this);
41void ^?{}(signal_once * this);
42
[db6f06a]43void wait( signal_once * );
44void signal( signal_once * );
45
[bd98b58]46//-----------------------------------------------------------------------------
47// Cluster
48struct cluster {
[5ea06d6]49 __thread_queue_t ready_queue;
[db6f06a]50 spinlock lock;
[bd98b58]51};
52
53void ?{}(cluster * this);
54void ^?{}(cluster * this);
55
56//-----------------------------------------------------------------------------
57// Processor
[0c78741]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)
[db6f06a]61struct FinishAction {
62 FinishOpCode action_code;
[348006f]63 thread_desc * thrd;
[db6f06a]64 spinlock * lock;
[0c78741]65 spinlock ** locks;
66 unsigned short lock_count;
67 thread_desc ** thrds;
68 unsigned short thrd_count;
[8fcbb4c]69};
[db6f06a]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) {}
[8fcbb4c]76
[c84e80a]77struct processor {
[8fcbb4c]78 struct processorCtx_t * runner;
[bd98b58]79 cluster * cltr;
[c3acb841]80 coroutine_desc * current_coroutine;
[348006f]81 thread_desc * current_thread;
[8def349]82 pthread_t kernel_thread;
[db6f06a]83
84 signal_once terminated;
85 volatile bool is_terminated;
86
87 struct FinishAction finish;
[c81ebf9]88
89 struct alarm_node_t * preemption_alarm;
90 unsigned int preemption;
91
92 unsigned short disable_preempt_count;
93
94 bool pending_preemption;
[c84e80a]95};
96
[8def349]97void ?{}(processor * this);
[bd98b58]98void ?{}(processor * this, cluster * cltr);
[c84e80a]99void ^?{}(processor * this);
100
[8118303]101#endif //KERNEL_H
102
103// Local Variables: //
[fa21ac9]104// mode: CFA //
105// tab-width: 6 //
[8118303]106// End: //
Note: See TracBrowser for help on using the repository browser.