Changeset f6f7b52 for libcfa/src


Ignore:
Timestamp:
Jan 16, 2025, 1:27:27 PM (7 weeks ago)
Author:
kyoung <lseo@…>
Branches:
master
Children:
9c65169
Parents:
3b21c96
git-author:
kyoung <lseo@…> (01/15/25 22:56:36)
git-committer:
kyoung <lseo@…> (01/16/25 13:27:27)
Message:

fixed a parser bug to generate correct ast for waitfor.

added a test program to check if we are respecting waitfor lexical priority.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified libcfa/src/concurrency/monitor.cfa

    r3b21c96 rf6f7b52  
    99// Author           : Thierry Delisle
    1010// Created On       : Thd Feb 23 12:27:26 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Nov 27 12:13:14 2024
    13 // Update Count     : 72
     11// Last Modified By : Kyoung Seo
     12// Last Modified On : Thd Jan 16 12:59:00 2025
     13// Update Count     : 73
    1414//
    1515
     
    922922static inline [thread$ *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor$ * monitors [], __lock_size_t count ) {
    923923        __queue_t(thread$) & entry_queue = monitors[0]->entry_queue;
    924 
    925 #if 0
    926         #if defined( __CFA_WITH_VERIFY__ )
    927                 thread$ * last = 0p;
    928         #endif
    929         // For each thread in the entry-queue
    930         for ( thread$ ** thrd_it = &entry_queue.head; (*thrd_it) != 1p; thrd_it = &get_next(**thrd_it) ) {
    931                 thread$ * curr = *thrd_it;
    932 
    933                 /* paranoid */ verifyf( !last || last->user_link.next == curr, "search not making progress, from %p (%p) to %p",
    934                                                                 last, last->user_link.next, curr );
    935                 /* paranoid */ verifyf( curr != last, "search not making progress, from %p to %p", last, curr );
    936 
    937                 // For each acceptable check if it matches
    938                 int i = 0;
    939                 __acceptable_t * end = end(mask);
    940                 __acceptable_t * begin = begin(mask);
    941                 for ( __acceptable_t * it = begin; it != end; it++, i++ ) {
    942                         // Check for match
    943                         if ( *it == curr->monitors ) {
    944                                 // If match, return it after removeing it from the entry queue
    945                                 return [remove( entry_queue, thrd_it ), i];
    946                         }
    947                 }
    948 
    949                 #if defined( __CFA_WITH_VERIFY__ )
    950                         last = curr;
    951                 #endif
    952         }
    953 #else
    954924        // For each acceptable (respect lexical priority in waitfor statement)
    955         __acceptable_t * it = end(mask); it--;                          // end is passed the last node, so backup
    956         for ( int i = mask.size - 1; i >= 0; i -= 1, it-- ) {
     925        int i = 0;
     926        __acceptable_t * end = end(mask);
     927        __acceptable_t * begin = begin(mask);
     928        for ( __acceptable_t * it = begin; it != end; it++, i++ ) {
    957929                #if defined( __CFA_WITH_VERIFY__ )
    958930                thread$ * last = 0p;
     
    977949                } // for
    978950        } // for
    979 #endif
    980951        return [0, -1];
    981952}
Note: See TracChangeset for help on using the changeset viewer.