source: libcfa/src/bits/weakso_locks.hfa @ c0363be

Last change on this file since c0363be was 43eb8e9, checked in by Peter A. Buhr <pabuhr@…>, 14 months ago

remove unnecessary include bits/sequence.hfa

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[ab1b971]1//
2// Cforall Version 1.0.0 Copyright (C) 2021 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// bits/weakso_locks.hfa -- PUBLIC
8// Runtime locks that are compiled out when used without linking the runtime
9// thread system.
10//
11// Author           : Thierry Delisle
12// Created On       : Thu Jan 21 19:46:50 2021
13// Last Modified By :
14// Last Modified On :
15// Update Count     :
16//
17
[352cbc2]18#pragma once
19
[ab1b971]20#include "bits/locks.hfa"
[55b060d]21#include "bits/collections.hfa"
22#include "collections/list.hfa"
[ab1b971]23
[73bf7ddc]24struct select_node;
[ab1b971]25
26//-----------------------------------------------------------------------------
27// Blocking Locks
28struct blocking_lock {
29        // Spin lock used for mutual exclusion
30        __spinlock_t lock;
31
32        // List of blocked threads
[73bf7ddc]33        dlist( select_node ) blocked_threads;
[ab1b971]34
35        // Count of current blocked threads
36        size_t wait_count;
37
38        // Flag if the lock allows multiple acquisition
39        bool multi_acquisition;
40
41        // Flag if lock can be released by non owner
42        bool strict_owner;
43
44        // Current thread owning the lock
[e84ab3d]45        struct thread$ * owner;
[ab1b971]46
47        // Number of recursion level
48        size_t recursion_count;
49};
50
51void  ?{}( blocking_lock & this, bool multi_acquisition, bool strict_owner ) OPTIONAL_THREAD;
52void ^?{}( blocking_lock & this ) OPTIONAL_THREAD;
53
54void lock( blocking_lock & this ) OPTIONAL_THREAD;
55bool try_lock( blocking_lock & this ) OPTIONAL_THREAD;
56void unlock( blocking_lock & this ) OPTIONAL_THREAD;
[e84ab3d]57void on_notify( blocking_lock & this, struct thread$ * t ) OPTIONAL_THREAD;
[fece3d9]58size_t on_wait( blocking_lock & this, void (*pp_fn)( void * ), void * pp_datum ) OPTIONAL_THREAD;
[22b7579]59void on_wakeup( blocking_lock & this, size_t ) OPTIONAL_THREAD;
[ab1b971]60size_t wait_count( blocking_lock & this ) OPTIONAL_THREAD;
[73bf7ddc]61bool register_select( blocking_lock & this, select_node & node ) OPTIONAL_THREAD;
62bool unregister_select( blocking_lock & this, select_node & node ) OPTIONAL_THREAD;
[bbecdd4]63bool on_selected( blocking_lock & this, select_node & node ) OPTIONAL_THREAD;
[bf55f32]64blocking_lock __CFA_select_get_type( blocking_lock this ) OPTIONAL_THREAD;
[ab1b971]65
66//----------
67struct multiple_acquisition_lock {
68        inline blocking_lock;
69};
70
71
72static inline void  ?{}( multiple_acquisition_lock & this ) {((blocking_lock &)this){ true, false };}
73static inline void ^?{}( multiple_acquisition_lock & this ) {}
[f19497c]74static inline void   lock     ( multiple_acquisition_lock & this ) { lock    ( (blocking_lock &)this ); }
[d27b6be]75static inline bool   try_lock ( multiple_acquisition_lock & this ) { return try_lock( (blocking_lock &)this ); }
[f19497c]76static inline void   unlock   ( multiple_acquisition_lock & this ) { unlock  ( (blocking_lock &)this ); }
[fece3d9]77static inline size_t on_wait  ( multiple_acquisition_lock & this, void (*pp_fn)( void * ), void * pp_datum ) { return on_wait ( (blocking_lock &)this, pp_fn, pp_datum ); }
[22b7579]78static inline void   on_wakeup( multiple_acquisition_lock & this, size_t v ) { on_wakeup ( (blocking_lock &)this, v ); }
[b2f3880]79static inline void   on_notify( multiple_acquisition_lock & this, struct thread$ * t ){ on_notify( (blocking_lock &)this, t ); }
[73bf7ddc]80static inline bool   register_select( multiple_acquisition_lock & this, select_node & node ) { return register_select( (blocking_lock &)this, node ); }
81static inline bool   unregister_select( multiple_acquisition_lock & this, select_node & node ) { return unregister_select( (blocking_lock &)this, node ); }
[bbecdd4]82static inline bool   on_selected( multiple_acquisition_lock & this, select_node & node ) { return on_selected( (blocking_lock &)this, node ); }
[55b060d]83multiple_acquisition_lock __CFA_select_get_type( multiple_acquisition_lock this );
Note: See TracBrowser for help on using the repository browser.