Changes in / [2ab67b9:8f61052c]


Ignore:
Files:
13 added
16 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • Jenkinsfile

    r2ab67b9 r8f61052c  
    2828                wrap([$class: 'TimestamperBuildWrapper']) {
    2929
    30                         notify_server(0)
     30                        notify_server(1)
    3131
    3232                        prepare_build()
    3333
    3434                        checkout()
    35 
    36                         notify_server(0)
    3735
    3836                        build()
  • doc/LaTeXmacros/lstlang.sty

    r2ab67b9 r8f61052c  
    107107\lstdefinelanguage{CFA}[ANSI]{C}{
    108108        morekeywords={
    109                 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, __attribute,
     109                _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, _Atomic, __attribute,
    110110                __attribute__, auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__,
    111                 __const, __const__, disable, dtype, enable, __extension__, fallthrough, fallthru,
    112                 finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, _Noreturn, one_t,
    113                 otype, restrict, _Static_assert, throw, throwResume, trait, try, ttype, typeof, __typeof,
    114                 __typeof__, zero_t},
    115         morekeywords=[2]{
    116                 accept, _Atomic, coroutine, is_coroutine, is_monitor, is_thread, monitor, mutex, nomutex,
    117                 resume, signal, signal_block, suspend, thread, _Thread_local, wait, yield},
     111                __const, __const__, coroutine, disable, dtype, enable, __extension__, fallthrough, fallthru,
     112                finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, monitor, mutex,
     113                _Noreturn, one_t, otype, restrict, _Static_assert, thread, _Thread_local, throw, throwResume,
     114                trait, try, ttype, typeof, __typeof, __typeof__, zero_t},
    118115}
    119116
  • doc/proposals/concurrency/.gitignore

    r2ab67b9 r8f61052c  
    1 build/*.aux
    2 build/*.acn
    3 build/*.acr
    4 build/*.alg
    5 build/*.bbl
    6 build/*.blg
    7 build/*.brf
    8 build/*.dvi
    9 build/*.glg
    10 build/*.glo
    11 build/*.gls
    12 build/*.idx
    13 build/*.ind
    14 build/*.ist
    15 build/*.log
    16 build/*.out
    17 build/*.ps
    18 build/*.tex
    19 build/*.toc
    20 *.pdf
    21 
    22 examples
     1concurrency.aux
     2concurrency.acn
     3concurrency.acr
     4concurrency.alg
     5concurrency.bbl
     6concurrency.blg
     7concurrency.brf
     8concurrency.dvi
     9concurrency.glg
     10concurrency.glo
     11concurrency.gls
     12concurrency.idx
     13concurrency.ind
     14concurrency.ist
     15concurrency.log
     16concurrency.out
     17concurrency.pdf
     18concurrency.ps
     19version.aux
     20monitor.tex
     21ext_monitor.tex
  • doc/proposals/concurrency/Makefile

    r2ab67b9 r8f61052c  
    11## Define the appropriate configuration variables.
    22
    3 TeXLIB = .:./style:./text:./annex:./build:../../LaTeXmacros:../../LaTeXmacros/listings:../../LaTeXmacros/enumitem:~/bibliographies:
    4 LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error -output-directory=build -interaction=nonstopmode
    5 BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex -terse
     3TeXLIB = .:../../LaTeXmacros:../../LaTeXmacros/listings:../../LaTeXmacros/enumitem:~/bibliographies:
     4LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error
     5BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex
    66
    77## Define the text source files.
    88
    99SOURCES = ${addsuffix .tex, \
    10 thesis \
    11 style/style \
    12 style/cfa-format \
    13 annex/glossary \
    14 text/intro \
    15 text/basics \
    16 text/concurrency \
    17 text/parallelism \
     10concurrency \
     11style \
     12cfa-format \
     13glossary \
    1814}
    1915
    20 FIGURES = ${addprefix build/, ${addsuffix .tex, \
     16FIGURES = ${addsuffix .tex, \
    2117        monitor \
    2218        ext_monitor \
    23 }}
     19}
    2420
    2521PICTURES = ${addsuffix .pstex, \
     
    3430## Define the documents that need to be made.
    3531
    36 DOCUMENT = thesis.pdf
     32DOCUMENT = concurrency.pdf
    3733
    3834# Directives #
     
    4137
    4238clean :
    43         @rm -fv ${DOCUMENT} \
    44         build/*.acn     \
    45         build/*.acr     \
    46         build/*.alg     \
    47         build/*.aux     \
    48         build/*.bbl     \
    49         build/*.blg     \
    50         build/*.brf     \
    51         build/*.cf      \
    52         build/*.dvi     \
    53         build/*.glg     \
    54         build/*.glo     \
    55         build/*.gls     \
    56         build/*.ist     \
    57         build/*.idx     \
    58         build/*.ilg     \
    59         build/*.ind     \
    60         build/*.log     \
    61         build/*.out     \
    62         build/*.ps      \
    63         build/*.pstex_t \
    64         build/*.tex     \
    65         build/*.toc     \
    66 
     39        rm -f *.bbl *.aux *.dvi *.idx *.ilg *.ind *.brf *.out *.log *.toc *.blg *.pstex_t *.cf *.glg *.glo *.gls *.ist *.acn *.acr *.alg \
     40                ${FIGURES} ${PICTURES} ${PROGRAMS} ${GRAPHS} ${basename ${DOCUMENT}}.ps ${DOCUMENT}
    6741
    6842# File Dependencies #
    6943
    70 ${DOCUMENT} : build/${basename ${DOCUMENT}}.ps
     44${DOCUMENT} : ${basename ${DOCUMENT}}.ps
    7145        ps2pdf $<
    7246
    73 build/${basename ${DOCUMENT}}.ps : build/${basename ${DOCUMENT}}.dvi
     47${basename ${DOCUMENT}}.ps : ${basename ${DOCUMENT}}.dvi
    7448        dvips $< -o $@
    7549
    76 build/${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex ../../LaTeXmacros/common.tex ../../LaTeXmacros/indexstyle
    77 
    78         @ if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi                           # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
    79         @ echo "Citation lookup"                                                                                        # Must have *.aux file containing citations for bibtex
    80         @ if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename ${notdir $@}}.tex ; fi
    81         @ echo "Citation Pass 1"
    82         @ -${BibTeX} ${basename $@}                                                                                     # Some citations reference others so run steps again to resolve these citations
    83         @ echo "Citation Pass 2"
    84         @ ${LaTeX} ${basename ${notdir $@}}.tex
    85         @ -${BibTeX} ${basename $@}
    86         @ echo "Glossary"
    87         makeglossaries -q -s ${basename $@}.ist ${basename $@}                                          # Make index from *.aux entries and input index at end of document
    88         @ echo ".dvi generation"
    89         @ -build/bump_ver.sh
    90         @ ${LaTeX} ${basename ${notdir $@}}.tex                                                                 # Run again to get index title into table of contents
     50${basename ${DOCUMENT}}.dvi : Makefile ${GRAPHS} ${PROGRAMS} ${PICTURES} ${FIGURES} ${SOURCES} ${basename ${DOCUMENT}}.tex \
     51                ../../LaTeXmacros/common.tex ../../LaTeXmacros/indexstyle
     52        # Conditionally create an empty *.ind (index) file for inclusion until makeindex is run.
     53        if [ ! -r ${basename $@}.ind ] ; then touch ${basename $@}.ind ; fi
     54        # Must have *.aux file containing citations for bibtex
     55        if [ ! -r ${basename $@}.aux ] ; then ${LaTeX} ${basename $@}.tex ; fi
     56        -${BibTeX} ${basename $@}
     57        # Some citations reference others so run steps again to resolve these citations
     58        ${LaTeX} ${basename $@}.tex
     59        -${BibTeX} ${basename $@}
     60        # Make index from *.aux entries and input index at end of document
     61        makeglossaries ${basename $@}
     62        #${LaTeX} ${basename $@}.tex
     63        # Run again to get index title into table of contents
     64        ${LaTeX} ${basename $@}.tex
     65        -./bump_ver.sh
     66        ${LaTeX} ${basename $@}.tex
    9167
    9268
     
    9672## Define the default recipes.
    9773
    98 build/%.tex : figures/%.fig
     74%.tex : %.fig
    9975        fig2dev -L eepic $< > $@
    10076
    101 build/%.ps : figures/%.fig
     77%.ps : %.fig
    10278        fig2dev -L ps $< > $@
    10379
    104 build/%.pstex : figures/%.fig
     80%.pstex : %.fig
    10581        fig2dev -L pstex $< > $@
    10682        fig2dev -L pstex_t -p $@ $< > $@_t
  • src/libcfa/concurrency/monitor

    r2ab67b9 r8f61052c  
    5959        unsigned short count;                           //Number of criterions in the criteria
    6060        __condition_node_t * next;                      //Intrusive linked list Next field
    61         uintptr_t user_info;                            //Custom user info accessible before signalling
    6261};
    6362
     
    8685}
    8786
    88 void wait( condition * this, uintptr_t user_info = 0 );
    89 bool signal( condition * this );
    90 bool signal_block( condition * this );
    91 static inline bool is_empty( condition * this ) { return !this->blocked.head; }
    92 uintptr_t front( condition * this );
    93 
     87void wait( condition * this );
     88void signal( condition * this );
     89void signal_block( condition * this );
    9490#endif //MONITOR_H
  • src/libcfa/concurrency/monitor.c

    r2ab67b9 r8f61052c  
    137137}
    138138
    139 void ?{}(__condition_node_t * this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info ) {
    140         this->waiting_thread = waiting_thread;
    141         this->count = count;
    142         this->next = NULL;
    143         this->user_info = user_info;
    144 }
    145 
    146 void ?{}(__condition_criterion_t * this ) {
    147         this->ready  = false;
    148         this->target = NULL;
    149         this->owner  = NULL;
    150         this->next   = NULL;
    151 }
    152 
    153 void ?{}(__condition_criterion_t * this, monitor_desc * target, __condition_node_t * owner ) {
    154         this->ready  = false;
    155         this->target = target;
    156         this->owner  = owner;
    157         this->next   = NULL;
     139void debug_break() __attribute__(( noinline ))
     140{
     141       
    158142}
    159143
    160144//-----------------------------------------------------------------------------
    161145// Internal scheduling
    162 void wait( condition * this, uintptr_t user_info = 0 ) {
     146void wait( condition * this ) {
    163147        LIB_DEBUG_PRINT_SAFE("Waiting\n");
    164148
     
    176160        LIB_DEBUG_PRINT_SAFE("count %i\n", count);
    177161
    178         __condition_node_t waiter = { this_thread(), count, user_info };
     162        __condition_node_t waiter;
     163        waiter.waiting_thread = this_thread();
     164        waiter.count = count;
     165        waiter.next = NULL;
    179166
    180167        __condition_criterion_t criteria[count];
    181168        for(int i = 0; i < count; i++) {
    182                 (&criteria[i]){ this->monitors[i], &waiter };
     169                criteria[i].ready  = false;
     170                criteria[i].target = this->monitors[i];
     171                criteria[i].owner  = &waiter;
     172                criteria[i].next   = NULL;
    183173                LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] );
    184174        }
     
    212202        ScheduleInternal( locks, count, threads, thread_count );
    213203
     204        debug_break();
    214205        //WE WOKE UP
    215206
     
    221212}
    222213
    223 bool signal( condition * this ) {
    224         if( is_empty( this ) ) {
     214void signal( condition * this ) {
     215        if( !this->blocked.head ) {
    225216                LIB_DEBUG_PRINT_SAFE("Nothing to signal\n");
    226                 return false;
     217                return;
    227218        }
    228219
     
    266257        //Release
    267258        unlock_all( this->monitors, count );
    268 
    269         return true;
    270 }
    271 
    272 bool signal_block( condition * this ) {
     259}
     260
     261void signal_block( condition * this ) {
    273262        if( !this->blocked.head ) {
    274263                LIB_DEBUG_PRINT_SAFE("Nothing to signal\n");
    275                 return false;
     264                return;
    276265        }
    277266
     
    287276
    288277        //create creteria
    289         __condition_node_t waiter = { this_thread(), count, 0 };
     278        __condition_node_t waiter;
     279        waiter.waiting_thread = this_thread();
     280        waiter.count = count;
     281        waiter.next = NULL;
    290282
    291283        __condition_criterion_t criteria[count];
    292284        for(int i = 0; i < count; i++) {
    293                 (&criteria[i]){ this->monitors[i], &waiter };
    294285                LIB_DEBUG_PRINT_SAFE( "Criterion %p\n", &criteria[i] );
     286                criteria[i].ready  = false;
     287                criteria[i].owner  = &waiter;
     288                criteria[i].next   = NULL;
     289                criteria[i].target = this->monitors[i];
    295290                push( &criteria[i].target->signal_stack, &criteria[i] );
    296291        }
     
    308303
    309304        LIB_DEBUG_PRINT_SAFE( "Waiting on signal block\n" );
     305        debug_break();
    310306
    311307        //Everything is ready to go to sleep
    312308        ScheduleInternal( locks, count, &signallee, 1 );
    313309
     310        debug_break();
    314311        LIB_DEBUG_PRINT_SAFE( "Back from signal block\n" );
    315312
     
    318315        restore_recursion( this->monitors, recursions, count );
    319316        unlock_all( locks, count );
    320 
    321         return true;
    322 }
    323 
    324 uintptr_t front( condition * this ) {
    325         LIB_DEBUG_DO(
    326                 if( is_empty(this) ) {
    327                         abortf( "Attempt to access user data on an empty condition.\n"
    328                     "Possible cause is not checking if the condition is empty before reading stored data." );
    329                 }
    330         );
    331         return this->blocked.head->user_info;
    332317}
    333318
  • src/tests/sched-int-block.c

    r2ab67b9 r8f61052c  
    1010
    1111monitor global_data_t {
    12         thread_desc * last_thread;
    13         thread_desc * last_signaller;
     12        state_t state;
     13        bool ran;
    1414};
    1515
    1616void ?{} ( global_data_t * this ) {
    17         this->last_thread = NULL;
    18         this->last_signaller = NULL;
     17        this->state = BARGE;
    1918}
    2019
     
    2928//------------------------------------------------------------------------------
    3029void wait_op( global_data_t * mutex a, global_data_t * mutex b, unsigned i ) {
    31         wait( &cond, (uintptr_t)this_thread() );
     30        wait( &cond );
     31        a->ran = b->ran = true;
    3232
    3333        yield( ((unsigned)rand48()) % 10 );
    3434
    35         if(a->last_thread != a->last_signaller || b->last_thread != b->last_signaller ) {
    36                 sout | "ERROR Barging detected, expected" | a->last_signaller | b->last_signaller | "got" | a->last_thread | b->last_thread | endl;
     35        if(a->state != SIGNAL || b->state != SIGNAL) {
     36                sout | "ERROR Barging detected" | a->state | b->state | endl;
    3737                abort();
    3838        }
    3939
    40         a->last_thread = b->last_thread = this_thread();
     40        a->state = b->state = WAITED;
    4141
    4242        yield( ((unsigned)rand48()) % 10 );
     
    5454        yield( ((unsigned)rand48()) % 10 );
    5555
    56         a->last_thread = b->last_thread = a->last_signaller = b->last_signaller = this_thread();
     56        a->ran = b->ran = false;
     57        a->state = b->state = SIGNAL;
    5758
    58         if( !is_empty( &cond ) ) {
     59        signal_block( &cond );
    5960
    60                 thread_desc * next = front( &cond );
     61        yield( ((unsigned)rand48()) % 10 );
    6162
    62                 if( ! signal_block( &cond ) ) {
    63                         sout | "ERROR expected to be able to signal" | endl;
    64                         abort();
    65                 }
    66 
    67                 yield( ((unsigned)rand48()) % 10 );
    68 
    69                 if(a->last_thread != next || b->last_thread != next) {
    70                         sout | "ERROR Barging detected, expected" | next | "got" | a->last_thread | b->last_thread | endl;
     63        assert(a->ran == b->ran);
     64        if(a->ran)
     65        {
     66                if(a->state != WAITED || b->state != WAITED) {
     67                        sout | "ERROR Barging detected" | a->state | b->state | endl;
    7168                        abort();
    7269                }
     
    8481//------------------------------------------------------------------------------
    8582void barge_op( global_data_t * mutex a ) {
    86         a->last_thread = this_thread();
     83        a->state = BARGE;
    8784}
    8885
  • src/tests/sched-int-disjoint.c

    r2ab67b9 r8f61052c  
    7878        signal( &cond, a, &data );
    7979
    80         yield( (unsigned)rand48() % 10 );
     80        int pauses = (unsigned)rand48() % 10;
     81        for(int i = 0; i < pauses; i++) {
     82                yield();
     83        }
    8184
    8285        //This is technically a mutual exclusion violation but the mutex monitor protects us
Note: See TracChangeset for help on using the changeset viewer.