source: src/libcfa/concurrency/kernel@ d6ff3ff

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 d6ff3ff was bdeba0b, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Removed signal_once type, use semaphore instead

  • 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
[b227f68]30bool try_lock ( spinlock * DEBUG_CTX_PARAM2 );
31void lock ( spinlock * DEBUG_CTX_PARAM2 );
32void lock_yield( spinlock * DEBUG_CTX_PARAM2 );
33void unlock ( spinlock * );
[db6f06a]34
[bdeba0b]35struct semaphore {
36 spinlock lock;
37 int count;
38 __thread_queue_t waiting;
[9c31349]39};
40
[bdeba0b]41void ?{}(semaphore * this, int count = 1);
42void ^?{}(semaphore * this);
43void P(semaphore * this);
44void V(semaphore * this);
[9c31349]45
[db6f06a]46
[bd98b58]47//-----------------------------------------------------------------------------
48// Cluster
49struct cluster {
[5ea06d6]50 __thread_queue_t ready_queue;
[db6f06a]51 spinlock lock;
[bd98b58]52};
53
54void ?{}(cluster * this);
55void ^?{}(cluster * this);
56
57//-----------------------------------------------------------------------------
58// Processor
[0c78741]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)
[db6f06a]62struct FinishAction {
63 FinishOpCode action_code;
[348006f]64 thread_desc * thrd;
[db6f06a]65 spinlock * lock;
[0c78741]66 spinlock ** locks;
67 unsigned short lock_count;
68 thread_desc ** thrds;
69 unsigned short thrd_count;
[8fcbb4c]70};
[2ac095d]71static inline void ?{}(FinishAction * this) {
[db6f06a]72 this->action_code = No_Action;
73 this->thrd = NULL;
74 this->lock = NULL;
75}
76static inline void ^?{}(FinishAction * this) {}
[8fcbb4c]77
[c84e80a]78struct processor {
[8fcbb4c]79 struct processorCtx_t * runner;
[bd98b58]80 cluster * cltr;
[8def349]81 pthread_t kernel_thread;
[2ac095d]82
[bdeba0b]83 semaphore terminated;
[db6f06a]84 volatile bool is_terminated;
85
86 struct FinishAction finish;
[c81ebf9]87
88 struct alarm_node_t * preemption_alarm;
89 unsigned int preemption;
90
91 bool pending_preemption;
[4e6fb8e]92
93 char * last_enable;
[c84e80a]94};
95
[8def349]96void ?{}(processor * this);
[bd98b58]97void ?{}(processor * this, cluster * cltr);
[c84e80a]98void ^?{}(processor * this);
99
[8118303]100#endif //KERNEL_H
101
102// Local Variables: //
[fa21ac9]103// mode: CFA //
104// tab-width: 6 //
[8118303]105// End: //
Note: See TracBrowser for help on using the repository browser.