Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/coroutines.c

    r8118303 r8def349  
     1//                              -*- Mode: CFA -*-
    12//
    23// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    1415//
    1516
     17#include "coroutines"
     18
    1619extern "C" {
    1720#include <stddef.h>
     
    2326}
    2427
    25 #include "coroutines"
     28#include "kernel"
    2629#include "libhdr.h"
    2730
    2831#define __CFA_INVOKE_PRIVATE__
    2932#include "invoke.h"
     33
     34extern processor * get_this_processor();
    3035
    3136//-----------------------------------------------------------------------------
     
    3540#define MinStackSize 1000
    3641static size_t pageSize = 0;                             // architecture pagesize HACK, should go in proper runtime singleton
    37 
    38 //Extra private desctructor for the main
    39 //FIXME the main should not actually allocate a stack
    40 //Since the main is never resumed the extra stack does not cause
    41 //any problem but it is wasted memory
    42 void ?{}(coStack_t* this, size_t size);
    43 void ?{}(coroutine* this, size_t size);
    44 
    45 //Main coroutine
    46 //FIXME do not construct a stack for the main
    47 coroutine main_coroutine = { 1000 };
    48 
    49 //Current coroutine
    50 //Will need to be in TLS when multi-threading is added
    51 coroutine* current_coroutine = &main_coroutine;
    5242
    5343//-----------------------------------------------------------------------------
     
    111101// is not inline (We can't inline Cforall in C)
    112102void suspend_no_inline(void) {
    113         LIB_DEBUG_PRINTF("Suspending back : to %p from %p\n", this_coroutine(), this_coroutine() ? this_coroutine()->last : (void*)-1);
    114 
    115103        suspend();
    116104}
     
    123111
    124112        // set new coroutine that task is executing
    125         current_coroutine = dst;                       
     113        get_this_processor()->current_coroutine = dst;                 
    126114
    127115        // context switch to specified coroutine
Note: See TracChangeset for help on using the changeset viewer.