source: src/libcfa/concurrency/kernel.c @ 7fbe450

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 7fbe450 was 8118303, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

First prototype of cfa threads running (1 thread on 1 processor)

  • Property mode set to 100644
File size: 1.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//
8// kernel.c --
9//
10// Author           : Thierry Delisle
11// Created On       : Tue Jan 17 12:27:26 2016
12// Last Modified By : Thierry Delisle
13// Last Modified On : --
14// Update Count     : 0
15//
16
17//Header
18#include "kernel"
19
20//C Includes
21#include <stdbool.h>
22
23//CFA Includes
24#include "libhdr.h"
25#include "threads"
26
27//Private includes
28#define __CFA_INVOKE_PRIVATE__
29#include "invoke.h"
30
31thread_h * the_thread = 0;
32
33void kernel_run( void ) {
34       
35        bool done = true;
36        coroutine* processor_cor = this_coroutine();
37        LIB_DEBUG_PRINTF("Kernel : processor cor is %p\n", processor_cor);
38
39        do {
40                thread_h * dst = the_thread;
41
42                LIB_DEBUG_PRINTF("Kernel : picked thread %p\n", dst);
43
44                // set new coroutine that task is executing
45                current_coroutine = &dst->c;
46
47                // context switch to specified coroutine
48                LIB_DEBUG_PRINTF("Kernel : switching to ctx %p (from %p)\n", current_coroutine, processor_cor);
49                CtxSwitch( processor_cor->stack.context, current_coroutine->stack.context );
50                // when CtxSwitch returns we are back in the processor coroutine
51        } while( ! done );
52}
53
54// Local Variables: //
55// mode: c //
56// tab-width: 4 //
57// End: //
Note: See TracBrowser for help on using the repository browser.