source: src/libcfa/concurrency/kernel@ fd344aa

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 fd344aa was 242a902, checked in by Rob Schluntz <rschlunt@…>, 8 years ago

Convert more library files to use references

  • 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 semaphore {
36 spinlock lock;
37 int count;
38 __thread_queue_t waiting;
39};
40
41void ?{}(semaphore & this, int count = 1);
42void ^?{}(semaphore & this);
43void P(semaphore * this);
44void V(semaphore * this);
45
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 semaphore 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.