Changeset 348006f


Ignore:
Timestamp:
Mar 15, 2017, 4:20:26 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
29f44a74
Parents:
84c52a8
Message:

Renamed thread to thread_desc

Location:
src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/bench.c

    r84c52a8 r348006f  
    150150//=======================================
    151151
    152 struct ThreadDummy { thread t; };
     152struct ThreadDummy { thread_desc t; };
    153153DECL_THREAD(ThreadDummy);
    154154void main(ThreadDummy * this) {}
     
    180180    int N;
    181181    long long result;
    182     thread t;
     182    thread_desc t;
    183183};
    184184
  • src/examples/multicore.c

    r84c52a8 r348006f  
    22#include <thread>
    33
    4 struct MyThread { thread t; };
     4struct MyThread { thread_desc t; };
    55
    66DECL_THREAD(MyThread);
  • src/libcfa/concurrency/invoke.c

    r84c52a8 r348006f  
    2929
    3030extern void __suspend_internal(void);
    31 extern void __thread_signal_termination(struct thread*);
     31extern void __thread_signal_termination(struct thread_desc*);
    3232
    3333void CtxInvokeCoroutine(
     
    5757void CtxInvokeThread(
    5858      void (*main)(void *),
    59       struct thread *(*get_thread)(void *),
     59      struct thread_desc *(*get_thread)(void *),
    6060      void *this
    6161) {
    6262      __suspend_internal();
    6363
    64       struct thread* thrd = get_thread( this );
     64      struct thread_desc* thrd = get_thread( this );
    6565      struct coroutine_desc* cor = &thrd->c;
    6666      cor->state = Active;
  • src/libcfa/concurrency/invoke.h

    r84c52a8 r348006f  
    3535
    3636      struct simple_thread_list {
    37             struct thread * head;
    38             struct thread ** tail;
     37            struct thread_desc * head;
     38            struct thread_desc ** tail;
    3939      };
    4040
     
    4848      extern "Cforall" {
    4949            void ?{}( struct simple_thread_list * );
    50             void append( struct simple_thread_list *, struct thread * );
    51             struct thread * pop_head( struct simple_thread_list * );
     50            void append( struct simple_thread_list *, struct thread_desc * );
     51            struct thread_desc * pop_head( struct simple_thread_list * );
    5252
    5353            void ?{}(spinlock * this);
     
    8080      };
    8181
    82       struct thread {
     82      struct thread_desc {
    8383            struct coroutine_desc c;                 // coroutine body used to store context
    8484            struct signal_once terminated;      // indicate if execuation state is not halted
    85             struct thread * next;               // instrusive link field for threads
     85            struct thread_desc * next;               // instrusive link field for threads
    8686      };
    8787
  • src/libcfa/concurrency/kernel

    r84c52a8 r348006f  
    4949struct FinishAction {
    5050        FinishOpCode action_code;
    51         thread * thrd;
     51        thread_desc * thrd;
    5252        spinlock * lock;
    5353};
     
    6363        cluster * cltr;
    6464        coroutine_desc * current_coroutine;
    65         thread * current_thread;
     65        thread_desc * current_thread;
    6666        pthread_t kernel_thread;
    6767       
  • src/libcfa/concurrency/kernel.c

    r84c52a8 r348006f  
    4343KERNEL_STORAGE(cluster, systemCluster);
    4444KERNEL_STORAGE(processor, systemProcessor);
    45 KERNEL_STORAGE(thread, mainThread);
     45KERNEL_STORAGE(thread_desc, mainThread);
    4646KERNEL_STORAGE(machine_context_t, mainThread_context);
    4747
    4848cluster * systemCluster;
    4949processor * systemProcessor;
    50 thread * mainThread;
     50thread_desc * mainThread;
    5151
    5252//-----------------------------------------------------------------------------
     
    5959}
    6060
    61 thread * this_thread(void) {
     61thread_desc * this_thread(void) {
    6262        return this_processor->current_thread;
    6363}
     
    106106}
    107107
    108 void ?{}( thread * this, current_stack_info_t * info) {
     108void ?{}( thread_desc * this, current_stack_info_t * info) {
    109109        (&this->c){ info };
    110110}
     
    175175        LIB_DEBUG_PRINTF("Kernel : core %p starting\n", this);
    176176
    177         thread * readyThread = NULL;
     177        thread_desc * readyThread = NULL;
    178178        for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )
    179179        {
     
    202202// runThread runs a thread by context switching
    203203// from the processor coroutine to the target thread
    204 void runThread(processor * this, thread * dst) {
     204void runThread(processor * this, thread_desc * dst) {
    205205        coroutine_desc * proc_cor = get_coroutine(this->runner);
    206206        coroutine_desc * thrd_cor = get_coroutine(dst);
     
    293293//-----------------------------------------------------------------------------
    294294// Scheduler routines
    295 void ScheduleThread( thread * thrd ) {
     295void ScheduleThread( thread_desc * thrd ) {
    296296        assertf( thrd->next == NULL, "Expected null got %p", thrd->next );
    297297       
     
    301301}
    302302
    303 thread * nextThread(cluster * this) {
     303thread_desc * nextThread(cluster * this) {
    304304        lock( &this->lock );
    305         thread * head = pop_head( &this->ready_queue );
     305        thread_desc * head = pop_head( &this->ready_queue );
    306306        unlock( &this->lock );
    307307        return head;
     
    318318}
    319319
    320 void ScheduleInternal( thread * thrd ) {
     320void ScheduleInternal( thread_desc * thrd ) {
    321321        this_processor->finish.action_code = Schedule;
    322322        this_processor->finish.thrd = thrd;
     
    324324}
    325325
    326 void ScheduleInternal( spinlock * lock, thread * thrd ) {
     326void ScheduleInternal( spinlock * lock, thread_desc * thrd ) {
    327327        this_processor->finish.action_code = Release_Schedule;
    328328        this_processor->finish.lock = lock;
     
    339339        // SKULLDUGGERY: the mainThread steals the process main thread
    340340        // which will then be scheduled by the systemProcessor normally
    341         mainThread = (thread *)&mainThread_storage;
     341        mainThread = (thread_desc *)&mainThread_storage;
    342342        current_stack_info_t info;
    343343        mainThread{ &info };
     
    436436                this->condition = true;
    437437
    438                 thread * it;
     438                thread_desc * it;
    439439                while( it = pop_head( &this->blocked) ) {
    440440                        ScheduleThread( it );
     
    451451}
    452452
    453 void append( simple_thread_list * this, thread * t ) {
     453void append( simple_thread_list * this, thread_desc * t ) {
    454454        assert(this->tail != NULL);
    455455        *this->tail = t;
     
    457457}
    458458
    459 thread * pop_head( simple_thread_list * this ) {
    460         thread * head = this->head;
     459thread_desc * pop_head( simple_thread_list * this ) {
     460        thread_desc * head = this->head;
    461461        if( head ) {
    462462                this->head = head->next;
  • src/libcfa/concurrency/kernel_private.h

    r84c52a8 r348006f  
    2323//-----------------------------------------------------------------------------
    2424// Scheduler
    25 void ScheduleThread( thread * );
    26 thread * nextThread(cluster * this);
     25void ScheduleThread( thread_desc * );
     26thread_desc * nextThread(cluster * this);
    2727
    2828void ScheduleInternal();
    2929void ScheduleInternal(spinlock * lock);
    30 void ScheduleInternal(thread * thrd);
    31 void ScheduleInternal(spinlock * lock, thread * thrd);
     30void ScheduleInternal(thread_desc * thrd);
     31void ScheduleInternal(spinlock * lock, thread_desc * thrd);
    3232
    3333//-----------------------------------------------------------------------------
     
    4242void main(processorCtx_t *);
    4343void start(processor * this);
    44 void runThread(processor * this, thread * dst);
     44void runThread(processor * this, thread_desc * dst);
    4545void finishRunning(processor * this);
    4646void spin(processor * this, unsigned int * spin_count);
  • src/libcfa/concurrency/monitor

    r84c52a8 r348006f  
    2424struct monitor_desc {
    2525        spinlock lock;
    26         thread * owner;
     26        thread_desc * owner;
    2727        simple_thread_list entry_queue;
    2828        unsigned int recursion;
  • src/libcfa/concurrency/monitor.c

    r84c52a8 r348006f  
    2121void enter(monitor_desc * this) {
    2222        lock( &this->lock );
    23         thread * thrd = this_thread();
     23        thread_desc * thrd = this_thread();
    2424
    2525        if( !this->owner ) {
     
    4848        lock( &this->lock );
    4949
    50         thread * thrd = this_thread();
     50        thread_desc * thrd = this_thread();
    5151        assert( thrd == this->owner );
    5252
     
    5555
    5656        //If we left the last level of recursion it means we are changing who owns the monitor
    57         thread * new_owner = 0;
     57        thread_desc * new_owner = 0;
    5858        if( this->recursion == 0) {
    5959                //Get the next thread in the list
  • src/libcfa/concurrency/thread

    r84c52a8 r348006f  
    2929trait is_thread(dtype T) {
    3030      void main(T* this);
    31       thread* get_thread(T* this);
     31      thread_desc* get_thread(T* this);
    3232};
    3333
    34 #define DECL_THREAD(X) thread* get_thread(X* this) { return &this->t; } void main(X* this)
     34#define DECL_THREAD(X) thread_desc* get_thread(X* this) { return &this->t; } void main(X* this)
    3535
    3636forall( dtype T | is_thread(T) )
     
    3939}
    4040
    41 static inline coroutine_desc* get_coroutine(thread* this) {
     41static inline coroutine_desc* get_coroutine(thread_desc* this) {
    4242        return &this->c;
    4343}
    4444
    45 thread * this_thread(void);
     45thread_desc * this_thread(void);
    4646
    4747//-----------------------------------------------------------------------------
    4848// Ctors and dtors
    49 void ?{}(thread* this);
    50 void ^?{}(thread* this);
     49void ?{}(thread_desc* this);
     50void ^?{}(thread_desc* this);
    5151
    5252//-----------------------------------------------------------------------------
  • src/libcfa/concurrency/thread.c

    r84c52a8 r348006f  
    4141// Thread ctors and dtors
    4242
    43 void ?{}(thread* this) {
     43void ?{}(thread_desc* this) {
    4444        (&this->c){};
    4545        this->c.name = "Anonymous Coroutine";
     
    4848}
    4949
    50 void ^?{}(thread* this) {
     50void ^?{}(thread_desc* this) {
    5151        ^(&this->c){};
    5252}
     
    7575void start( T* this ) {
    7676        coroutine_desc* thrd_c = get_coroutine(this);
    77         thread*  thrd_h = get_thread   (this);
     77        thread_desc*  thrd_h = get_thread   (this);
    7878        thrd_c->last = this_coroutine();
    7979        this_processor->current_coroutine = thrd_c;
     
    116116}
    117117
    118 // C Helper to signal the termination of a thread
     118// C Helper to signal the termination of a thread_desc
    119119// Used in invoke.c
    120120extern "C" {
    121         void __thread_signal_termination( thread * this ) {
     121        void __thread_signal_termination( thread_desc * this ) {
    122122                this->c.state = Halted;
    123123                LIB_DEBUG_PRINTF("Thread end : %p\n", this);
  • src/tests/monitor.c

    r84c52a8 r348006f  
    2727}
    2828
    29 struct MyThread { thread t; };
     29struct MyThread { thread_desc t; };
    3030
    3131DECL_THREAD(MyThread);
  • src/tests/multi-monitor.c

    r84c52a8 r348006f  
    1515
    1616struct MyThread {
    17         thread t;
     17        thread_desc t;
    1818        int target;
    1919};
  • src/tests/thread.c

    r84c52a8 r348006f  
    44#include <thread>
    55
    6 struct First { thread t; signal_once* lock; };
    7 struct Second { thread t; signal_once* lock; };
     6struct First { thread_desc t; signal_once* lock; };
     7struct Second { thread_desc t; signal_once* lock; };
    88
    99DECL_THREAD(First);
Note: See TracChangeset for help on using the changeset viewer.