Ignore:
Timestamp:
Jan 24, 2017, 11:45:13 AM (8 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:
60819df7
Parents:
63f78f0
Message:

cfa now supports processors which represent kernel threads, allowing basic parallelism

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/libcfa/concurrency/kernel

    r63f78f0 r8def349  
    2222#include "invoke.h"
    2323
     24extern "C" {
     25#include <pthread.h>
     26}
     27
    2428//-----------------------------------------------------------------------------
    2529// Cluster
    2630struct cluster {
    2731        simple_thread_list ready_queue;
     32        pthread_spinlock_t lock;
    2833};
    2934
     
    3843        coroutine * current_coroutine;
    3944        thread_h * current_thread;
    40         bool terminated;
     45        pthread_t kernel_thread;
     46        simple_lock lock;
     47        volatile bool terminated;
    4148};
    4249
     50void ?{}(processor * this);
    4351void ?{}(processor * this, cluster * cltr);
    4452void ^?{}(processor * this);
     
    5462void unlock( simple_lock * );
    5563
     64struct pthread_spinlock_guard {
     65        pthread_spinlock_t * lock;
     66};
     67
     68static inline void ?{}( pthread_spinlock_guard * this, pthread_spinlock_t * lock ) {
     69        this->lock = lock;
     70        pthread_spin_lock( this->lock );
     71}
     72
     73static inline void ^?{}( pthread_spinlock_guard * this ) {
     74        pthread_spin_unlock( this->lock );
     75}
     76
     77// //Simple spinlock implementation from
     78// //http://stackoverflow.com/questions/1383363/is-my-spin-lock-implementation-correct-and-optimal
     79// //Not optimal but correct
     80// #define VOL
     81
     82// struct simple_spinlock {
     83//      VOL int lock;
     84// };
     85
     86// extern VOL int __sync_lock_test_and_set( VOL int *, VOL int);
     87// extern void __sync_synchronize();
     88
     89// static inline void lock( simple_spinlock * this ) {
     90//     while (__sync_lock_test_and_set(&this->lock, 1)) {
     91//         // Do nothing. This GCC builtin instruction
     92//         // ensures memory barrier.
     93//     }
     94// }
     95
     96// static inline void unlock( simple_spinlock * this ) {
     97//     __sync_synchronize(); // Memory barrier.
     98//     this->lock = 0;
     99// }
     100
    56101#endif //KERNEL_H
    57102
Note: See TracChangeset for help on using the changeset viewer.