source: src/libcfa/concurrency/monitor.c @ 6ae8c92

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 6ae8c92 was 6ae8c92, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Changed lib-side waitfor to use a mask type instead of a pointer and an int. The accepted index is now in the mask type, everything else points to it

  • Property mode set to 100644
File size: 21.9 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// monitor_desc.c --
8//
9// Author           : Thierry Delisle
10// Created On       : Thd Feb 23 12:27:26 2017
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Mon Jul 31 14:59:05 2017
13// Update Count     : 3
14//
15
16#include "monitor"
17
18#include <stdlib>
19
20#include "libhdr.h"
21#include "kernel_private.h"
22
23//-----------------------------------------------------------------------------
24// Forward declarations
25static inline void set_owner( monitor_desc * this, thread_desc * owner );
26static inline thread_desc * next_thread( monitor_desc * this );
27static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & monitors );
28
29static inline void lock_all( spinlock ** locks, unsigned short count );
30static inline void lock_all( monitor_desc ** source, spinlock ** /*out*/ locks, unsigned short count );
31static inline void unlock_all( spinlock ** locks, unsigned short count );
32static inline void unlock_all( monitor_desc ** locks, unsigned short count );
33
34static inline void save_recursion   ( monitor_desc ** ctx, unsigned int * /*out*/ recursions, unsigned short count );
35static inline void restore_recursion( monitor_desc ** ctx, unsigned int * /*in */ recursions, unsigned short count );
36
37static inline void init     ( int count, monitor_desc ** monitors, __condition_node_t * waiter, __condition_criterion_t * criteria );
38static inline void init_push( int count, monitor_desc ** monitors, __condition_node_t * waiter, __condition_criterion_t * criteria );
39
40static inline thread_desc * check_condition( __condition_criterion_t * );
41static inline void brand_condition( condition * );
42static inline unsigned short insert_unique( thread_desc ** thrds, unsigned short end, thread_desc * val );
43
44static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t &, monitor_desc ** monitors, int count );
45
46static inline short count_max( const __waitfor_mask_t & mask );
47static inline short aggregate( monitor_desc ** storage, const __waitfor_mask_t & mask );
48static inline void  set_mask ( monitor_desc ** storage, short count, const __waitfor_mask_t & mask );
49
50//-----------------------------------------------------------------------------
51// Useful defines
52#define wait_ctx(thrd, user_info)                               /* Create the necessary information to use the signaller stack       */ \
53        __condition_node_t waiter = { thrd, count, user_info };   /* Create the node specific to this wait operation                   */ \
54        __condition_criterion_t criteria[count];                  /* Create the creteria this wait operation needs to wake up          */ \
55        init( count, monitors, &waiter, criteria );               /* Link everything together                                          */ \
56
57#define wait_ctx_primed(thrd, user_info)                        /* Create the necessary information to use the signaller stack       */ \
58        __condition_node_t waiter = { thrd, count, user_info };   /* Create the node specific to this wait operation                   */ \
59        __condition_criterion_t criteria[count];                  /* Create the creteria this wait operation needs to wake up          */ \
60        init_push( count, monitors, &waiter, criteria );          /* Link everything together and push it to the AS-Stack              */ \
61
62#define monitor_ctx( mons, cnt )              /* Define that create the necessary struct for internal/external scheduling operations */ \
63        monitor_desc ** monitors = mons;        /* Save the targeted monitors                                                          */ \
64        unsigned short count = cnt;             /* Save the count to a local variable                                                  */ \
65        unsigned int recursions[ count ];       /* Save the current recursion levels to restore them later                             */ \
66        spinlock *   locks     [ count ];       /* We need to pass-in an array of locks to BlockInternal                               */ \
67
68//-----------------------------------------------------------------------------
69// Enter/Leave routines
70
71
72extern "C" {
73        // Enter single monitor
74        static void __enter_monitor_desc( const __monitor_group_t & group ) {
75                monitor_desc * this = group.list[0];
76
77                // Lock the monitor spinlock, lock_yield to reduce contention
78                lock_yield( &this->lock DEBUG_CTX2 );
79                thread_desc * thrd = this_thread;
80
81                LIB_DEBUG_PRINT_SAFE("Kernel : %10p Entering mon %p (%p)\n", thrd, this, this->owner);
82
83                if( !this->owner ) {
84                        // No one has the monitor, just take it
85                        set_owner( this, thrd );
86
87                        LIB_DEBUG_PRINT_SAFE("Kernel :  mon is free \n");
88                }
89                else if( this->owner == thrd) {
90                        // We already have the monitor, just not how many times we took it
91                        verify( this->recursion > 0 );
92                        this->recursion += 1;
93
94                        LIB_DEBUG_PRINT_SAFE("Kernel :  mon already owned \n");
95                }
96                else if( is_accepted( this, group) ) {
97                        // Some one was waiting for us, enter
98                        set_owner( this, thrd );
99
100                        LIB_DEBUG_PRINT_SAFE("Kernel :  mon accepts \n");
101                }
102                else {
103                        LIB_DEBUG_PRINT_SAFE("Kernel :  blocking \n");
104
105                        // Some one else has the monitor, wait in line for it
106                        append( &this->entry_queue, thrd );
107                        BlockInternal( &this->lock );
108
109                        LIB_DEBUG_PRINT_SAFE("Kernel : %10p Entered  mon %p\n", thrd, this);
110
111                        // BlockInternal will unlock spinlock, no need to unlock ourselves
112                        return;
113                }
114
115                LIB_DEBUG_PRINT_SAFE("Kernel : %10p Entered  mon %p\n", thrd, this);
116
117                // Release the lock and leave
118                unlock( &this->lock );
119                return;
120        }
121
122        // Leave single monitor
123        void __leave_monitor_desc( monitor_desc * this ) {
124                // Lock the monitor spinlock, lock_yield to reduce contention
125                lock_yield( &this->lock DEBUG_CTX2 );
126
127                verifyf( this_thread == this->owner, "Expected owner to be %p, got %p (r: %i)", this_thread, this->owner, this->recursion );
128
129                // Leaving a recursion level, decrement the counter
130                this->recursion -= 1;
131
132                // If we haven't left the last level of recursion
133                // it means we don't need to do anything
134                if( this->recursion != 0) {
135                        unlock( &this->lock );
136                        return;
137                }
138
139                // Get the next thread, will be null on low contention monitor
140                thread_desc * new_owner = next_thread( this );
141
142                // We can now let other threads in safely
143                unlock( &this->lock );
144
145                //We need to wake-up the thread
146                WakeThread( new_owner );
147        }
148
149        // Leave the thread monitor
150        // last routine called by a thread.
151        // Should never return
152        void __leave_thread_monitor( thread_desc * thrd ) {
153                monitor_desc * this = &thrd->self_mon;
154
155                // Lock the monitor now
156                lock_yield( &this->lock DEBUG_CTX2 );
157
158                disable_interrupts();
159
160                thrd->self_cor.state = Halted;
161
162                verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i)", thrd, this->owner, this->recursion );
163
164                // Leaving a recursion level, decrement the counter
165                this->recursion -= 1;
166
167                // If we haven't left the last level of recursion
168                // it must mean there is an error
169                if( this->recursion != 0) { abortf("Thread internal monitor has unbalanced recursion"); }
170
171                // Fetch the next thread, can be null
172                thread_desc * new_owner = next_thread( this );
173
174                // Leave the thread, this will unlock the spinlock
175                // Use leave thread instead of BlockInternal which is
176                // specialized for this case and supports null new_owner
177                LeaveThread( &this->lock, new_owner );
178
179                // Control flow should never reach here!
180        }
181}
182
183// Enter multiple monitor
184// relies on the monitor array being sorted
185static inline void enter( __monitor_group_t monitors ) {
186        for(int i = 0; i < monitors.size; i++) {
187                __enter_monitor_desc( monitors );
188        }
189}
190
191// Leave multiple monitor
192// relies on the monitor array being sorted
193static inline void leave(monitor_desc ** monitors, int count) {
194        for(int i = count - 1; i >= 0; i--) {
195                __leave_monitor_desc( monitors[i] );
196        }
197}
198
199// Ctor for monitor guard
200// Sorts monitors before entering
201void ?{}( monitor_guard_t & this, monitor_desc ** m, int count, void (*func)() ) {
202        // Store current array
203        this.m = m;
204        this.count = count;
205
206        // Sort monitors based on address -> TODO use a sort specialized for small numbers
207        qsort(this.m, count);
208
209        // Save previous thread context
210        this.prev_mntrs = this_thread->monitors.list;
211        this.prev_count = this_thread->monitors.size;
212        this.prev_func  = this_thread->monitors.func;
213
214        // Update thread context (needed for conditions)
215        this_thread->monitors.list = m;
216        this_thread->monitors.size = count;
217        this_thread->monitors.func = func;
218
219        // Enter the monitors in order
220        __monitor_group_t group = {this.m, this.count, func};
221        enter( group );
222}
223
224
225// Dtor for monitor guard
226void ^?{}( monitor_guard_t & this ) {
227        // Leave the monitors in order
228        leave( this.m, this.count );
229
230        // Restore thread context
231        this_thread->monitors.list = this.prev_mntrs;
232        this_thread->monitors.size = this.prev_count;
233        this_thread->monitors.func = this.prev_func;
234}
235
236//-----------------------------------------------------------------------------
237// Internal scheduling types
238void ?{}(__condition_node_t & this, thread_desc * waiting_thread, unsigned short count, uintptr_t user_info ) {
239        this.waiting_thread = waiting_thread;
240        this.count = count;
241        this.next = NULL;
242        this.user_info = user_info;
243}
244
245void ?{}(__condition_criterion_t & this ) {
246        this.ready  = false;
247        this.target = NULL;
248        this.owner  = NULL;
249        this.next   = NULL;
250}
251
252void ?{}(__condition_criterion_t & this, monitor_desc * target, __condition_node_t * owner ) {
253        this.ready  = false;
254        this.target = target;
255        this.owner  = owner;
256        this.next   = NULL;
257}
258
259//-----------------------------------------------------------------------------
260// Internal scheduling
261void wait( condition * this, uintptr_t user_info = 0 ) {
262        brand_condition( this );
263
264        // Check that everything is as expected
265        assertf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );
266        verifyf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
267        verifyf( this->monitor_count < 32u, "Excessive monitor count (%i)", this->monitor_count );
268
269        // Create storage for monitor context
270        monitor_ctx( this->monitors, this->monitor_count );
271
272        // Create the node specific to this wait operation
273        wait_ctx( this_thread, user_info );
274
275        // Append the current wait operation to the ones already queued on the condition
276        // We don't need locks for that since conditions must always be waited on inside monitor mutual exclusion
277        append( &this->blocked, &waiter );
278
279        // Lock all monitors (aggregates the lock them as well)
280        lock_all( monitors, locks, count );
281
282        // DON'T unlock, ask the kernel to do it
283
284        // Save monitor state
285        save_recursion( monitors, recursions, count );
286
287        // Find the next thread(s) to run
288        unsigned short thread_count = 0;
289        thread_desc * threads[ count ];
290        for(int i = 0; i < count; i++) {
291                threads[i] = 0;
292        }
293
294        // Remove any duplicate threads
295        for( int i = 0; i < count; i++) {
296                thread_desc * new_owner = next_thread( monitors[i] );
297                thread_count = insert_unique( threads, thread_count, new_owner );
298        }
299
300        // Everything is ready to go to sleep
301        BlockInternal( locks, count, threads, thread_count );
302
303
304        // WE WOKE UP
305
306
307        // We are back, restore the owners and recursions
308        lock_all( locks, count );
309        restore_recursion( monitors, recursions, count );
310        unlock_all( locks, count );
311}
312
313bool signal( condition * this ) {
314        if( is_empty( this ) ) { return false; }
315
316        //Check that everything is as expected
317        verify( this->monitors );
318        verify( this->monitor_count != 0 );
319
320        //Some more checking in debug
321        LIB_DEBUG_DO(
322                thread_desc * this_thrd = this_thread;
323                if ( this->monitor_count != this_thrd->monitors.size ) {
324                        abortf( "Signal on condition %p made with different number of monitor(s), expected %i got %i", this, this->monitor_count, this_thrd->monitors.size );
325                }
326
327                for(int i = 0; i < this->monitor_count; i++) {
328                        if ( this->monitors[i] != this_thrd->monitors.list[i] ) {
329                                abortf( "Signal on condition %p made with different monitor, expected %p got %i", this, this->monitors[i], this_thrd->monitors.list[i] );
330                        }
331                }
332        );
333
334        unsigned short count = this->monitor_count;
335
336        // Lock all monitors
337        lock_all( this->monitors, NULL, count );
338
339        //Pop the head of the waiting queue
340        __condition_node_t * node = pop_head( &this->blocked );
341
342        //Add the thread to the proper AS stack
343        for(int i = 0; i < count; i++) {
344                __condition_criterion_t * crit = &node->criteria[i];
345                assert( !crit->ready );
346                push( &crit->target->signal_stack, crit );
347        }
348
349        //Release
350        unlock_all( this->monitors, count );
351
352        return true;
353}
354
355bool signal_block( condition * this ) {
356        if( !this->blocked.head ) { return false; }
357
358        //Check that everything is as expected
359        verifyf( this->monitors != NULL, "Waiting with no monitors (%p)", this->monitors );
360        verifyf( this->monitor_count != 0, "Waiting with 0 monitors (%i)", this->monitor_count );
361
362        // Create storage for monitor context
363        monitor_ctx( this->monitors, this->monitor_count );
364
365        // Lock all monitors (aggregates the locks them as well)
366        lock_all( monitors, locks, count );
367
368        // Create the node specific to this wait operation
369        wait_ctx_primed( this_thread, 0 )
370
371        //save contexts
372        save_recursion( monitors, recursions, count );
373
374        //Find the thread to run
375        thread_desc * signallee = pop_head( &this->blocked )->waiting_thread;
376        for(int i = 0; i < count; i++) {
377                set_owner( monitors[i], signallee );
378        }
379
380        //Everything is ready to go to sleep
381        BlockInternal( locks, count, &signallee, 1 );
382
383
384        // WE WOKE UP
385
386
387        //We are back, restore the owners and recursions
388        lock_all( locks, count );
389        restore_recursion( monitors, recursions, count );
390        unlock_all( locks, count );
391
392        return true;
393}
394
395// Access the user_info of the thread waiting at the front of the queue
396uintptr_t front( condition * this ) {
397        verifyf( !is_empty(this),
398                "Attempt to access user data on an empty condition.\n"
399                "Possible cause is not checking if the condition is empty before reading stored data."
400        );
401        return this->blocked.head->user_info;
402}
403
404//-----------------------------------------------------------------------------
405// External scheduling
406// cases to handle :
407//      - target already there :
408//              block and wake
409//      - dtor already there
410//              put thread on signaller stack
411//      - non-blocking
412//              return else
413//      - timeout
414//              return timeout
415//      - block
416//              setup mask
417//              block
418void __waitfor_internal( const __waitfor_mask_t & mask, int duration ) {
419        // This statment doesn't have a contiguous list of monitors...
420        // Create one!
421        short max = count_max( mask );
422        monitor_desc * mon_storage[max];
423        short actual_count = aggregate( mon_storage, mask );
424
425        // Create storage for monitor context
426        monitor_ctx( mon_storage, actual_count );
427
428        // Lock all monitors (aggregates the lock them as well)
429        lock_all( monitors, locks, count );
430
431        {
432                // Check if the entry queue
433                thread_desc * next; int index;
434                [next, index] = search_entry_queue( mask, monitors, count );
435
436                if( next ) {
437                        if( mask.clauses[index].is_dtor ) {
438                                #warning case not implemented
439                        }
440                        else {
441                                save_recursion( monitors, recursions, count );
442
443                                // Everything is ready to go to sleep
444                                BlockInternal( locks, count, &next, 1 );
445
446
447                                //WE WOKE UP
448
449
450                                //We are back, restore the owners and recursions
451                                lock_all( locks, count );
452                                restore_recursion( monitors, recursions, count );
453                                unlock_all( locks, count );
454                        }
455
456                        return index;
457                }
458        }
459
460
461        if( duration == 0 ) return -1;
462
463
464        verifyf( duration < 0, "Timeout on waitfor statments not supported yet.");
465
466
467        save_recursion( monitors, recursions, count );
468        set_mask( monitors, count, mask );
469
470
471        // Everything is ready to go to sleep
472        BlockInternal( locks, count );
473
474
475        //WE WOKE UP
476
477
478        //We are back, restore the owners and recursions
479        lock_all( locks, count );
480        restore_recursion( monitors, recursions, count );
481        unlock_all( locks, count );
482
483        return mask.accepted;
484}
485
486//-----------------------------------------------------------------------------
487// Utilities
488
489static inline void set_owner( monitor_desc * this, thread_desc * owner ) {
490        //Pass the monitor appropriately
491        this->owner = owner;
492
493        //We are passing the monitor to someone else, which means recursion level is not 0
494        this->recursion = owner ? 1 : 0;
495}
496
497static inline thread_desc * next_thread( monitor_desc * this ) {
498        //Check the signaller stack
499        __condition_criterion_t * urgent = pop( &this->signal_stack );
500        if( urgent ) {
501                //The signaller stack is not empty,
502                //regardless of if we are ready to baton pass,
503                //we need to set the monitor as in use
504                set_owner( this,  urgent->owner->waiting_thread );
505
506                return check_condition( urgent );
507        }
508
509        // No signaller thread
510        // Get the next thread in the entry_queue
511        thread_desc * new_owner = pop_head( &this->entry_queue );
512        set_owner( this, new_owner );
513
514        return new_owner;
515}
516
517static inline void init( int count, monitor_desc ** monitors, __condition_node_t * waiter, __condition_criterion_t * criteria ) {
518        for(int i = 0; i < count; i++) {
519                (criteria[i]){ monitors[i], waiter };
520        }
521
522        waiter->criteria = criteria;
523}
524
525static inline void init_push( int count, monitor_desc ** monitors, __condition_node_t * waiter, __condition_criterion_t * criteria ) {
526        for(int i = 0; i < count; i++) {
527                (criteria[i]){ monitors[i], waiter };
528                push( &criteria[i].target->signal_stack, &criteria[i] );
529        }
530
531        waiter->criteria = criteria;
532}
533
534static inline void lock_all( spinlock ** locks, unsigned short count ) {
535        for( int i = 0; i < count; i++ ) {
536                lock_yield( locks[i] DEBUG_CTX2 );
537        }
538}
539
540static inline void lock_all( monitor_desc ** source, spinlock ** /*out*/ locks, unsigned short count ) {
541        for( int i = 0; i < count; i++ ) {
542                spinlock * l = &source[i]->lock;
543                lock_yield( l DEBUG_CTX2 );
544                if(locks) locks[i] = l;
545        }
546}
547
548static inline void unlock_all( spinlock ** locks, unsigned short count ) {
549        for( int i = 0; i < count; i++ ) {
550                unlock( locks[i] );
551        }
552}
553
554static inline void unlock_all( monitor_desc ** locks, unsigned short count ) {
555        for( int i = 0; i < count; i++ ) {
556                unlock( &locks[i]->lock );
557        }
558}
559
560
561static inline void save_recursion   ( monitor_desc ** ctx, unsigned int * /*out*/ recursions, unsigned short count ) {
562        for( int i = 0; i < count; i++ ) {
563                recursions[i] = ctx[i]->recursion;
564        }
565}
566
567static inline void restore_recursion( monitor_desc ** ctx, unsigned int * /*in */ recursions, unsigned short count ) {
568        for( int i = 0; i < count; i++ ) {
569                ctx[i]->recursion = recursions[i];
570        }
571}
572
573// Function has 2 different behavior
574// 1 - Marks a monitors as being ready to run
575// 2 - Checks if all the monitors are ready to run
576//     if so return the thread to run
577static inline thread_desc * check_condition( __condition_criterion_t * target ) {
578        __condition_node_t * node = target->owner;
579        unsigned short count = node->count;
580        __condition_criterion_t * criteria = node->criteria;
581
582        bool ready2run = true;
583
584        for(    int i = 0; i < count; i++ ) {
585
586                // LIB_DEBUG_PRINT_SAFE( "Checking %p for %p\n", &criteria[i], target );
587                if( &criteria[i] == target ) {
588                        criteria[i].ready = true;
589                        // LIB_DEBUG_PRINT_SAFE( "True\n" );
590                }
591
592                ready2run = criteria[i].ready && ready2run;
593        }
594
595        // LIB_DEBUG_PRINT_SAFE( "Runing %i\n", ready2run );
596        return ready2run ? node->waiting_thread : NULL;
597}
598
599static inline void brand_condition( condition * this ) {
600        thread_desc * thrd = this_thread;
601        if( !this->monitors ) {
602                // LIB_DEBUG_PRINT_SAFE("Branding\n");
603                assertf( thrd->monitors.list != NULL, "No current monitor to brand condition %p", thrd->monitors.list );
604                this->monitor_count = thrd->monitors.size;
605
606                this->monitors = malloc( this->monitor_count * sizeof( *this->monitors ) );
607                for( int i = 0; i < this->monitor_count; i++ ) {
608                        this->monitors[i] = thrd->monitors.list[i];
609                }
610        }
611}
612
613static inline unsigned short insert_unique( thread_desc ** thrds, unsigned short end, thread_desc * val ) {
614        if( !val ) return end;
615
616        for(int i = 0; i <= end; i++) {
617                if( thrds[i] == val ) return end;
618        }
619
620        thrds[end] = val;
621        return end + 1;
622}
623
624static inline bool is_accepted( monitor_desc * this, const __monitor_group_t & group ) {
625        __acceptable_t * it = this->mask.clauses; // Optim
626        int count = this->mask.size;
627
628        // Check if there are any acceptable functions
629        if( !it ) return -1;
630
631        // If this isn't the first monitor to test this, there is no reason to repeat the test.
632        if( this != group[0] ) return group[0]->mask.accepted >= 0;
633
634        // For all acceptable functions check if this is the current function.
635        for( short i = 0; i < count; i++, it++ ) {
636                if( it->monitors == group ) {
637                        *this->mask.accepted = i;
638                        return true;
639                }
640        }
641
642        // No function matched
643        return false;
644}
645
646static inline [thread_desc *, int] search_entry_queue( const __waitfor_mask_t & mask, monitor_desc ** monitors, int count ) {
647
648        __thread_queue_t * entry_queue = &monitors[0]->entry_queue;
649
650        // For each thread in the entry-queue
651        for(    thread_desc ** thrd_it = &entry_queue->head;
652                *thrd_it;
653                thrd_it = &(*thrd_it)->next)
654        {
655                // For each acceptable check if it matches
656                int i;
657                __acceptable_t * end = mask.clauses + mask.size;
658                for( __acceptable_t * it = mask.clauses; it != end; it++, i++ ) {
659                        // Check if we have a match
660                        if( it->monitors == (*thrd_it)->monitors ) {
661
662                                // If we have a match return it
663                                // after removeing it from the entry queue
664                                return [remove( entry_queue, thrd_it ), i];
665                        }
666                }
667        }
668
669        return [0, -1];
670}
671
672static inline short count_max( const __waitfor_mask_t & mask ) {
673        short max = 0;
674        for( int i = 0; i < mask.size; i++ ) {
675                max += mask.clauses[i].monitors.size;
676        }
677        return max;
678}
679
680static inline short aggregate( monitor_desc ** storage, const __waitfor_mask_t & mask ) {
681        #warning function not implemented
682        return 0;
683}
684
685static inline void set_mask( monitor_desc ** storage, short count, const __waitfor_mask_t & mask ) {
686        for(int i = 0; i < count; i++) {
687                storage[i]->mask = mask;
688        }
689}
690
691
692void ?{}( __condition_blocked_queue_t & this ) {
693        this.head = NULL;
694        this.tail = &this.head;
695}
696
697void append( __condition_blocked_queue_t * this, __condition_node_t * c ) {
698        verify(this->tail != NULL);
699        *this->tail = c;
700        this->tail = &c->next;
701}
702
703__condition_node_t * pop_head( __condition_blocked_queue_t * this ) {
704        __condition_node_t * head = this->head;
705        if( head ) {
706                this->head = head->next;
707                if( !head->next ) {
708                        this->tail = &this->head;
709                }
710                head->next = NULL;
711        }
712        return head;
713}
714
715// Local Variables: //
716// mode: c //
717// tab-width: 4 //
718// End: //
Note: See TracBrowser for help on using the repository browser.