Skip to content

Commit

Permalink
base-fiasco/sel4: unified cancelable_lock.h
Browse files Browse the repository at this point in the history
On seL4 and L4/Fiasco, we employ a simple yielding spinlock as lock
implementation. Consequently these base platforms used to have a
simplified header. However, since the regular cancelable_lock has all
the member variables needed to implement a spinlock, we can simply use
the generic header on those two platforms too, just leaving some other
parts of the generic header unused. So at API level, the difference is
not visible.

Issue genodelabs#1832
  • Loading branch information
nfeske authored and chelmuth committed Mar 1, 2016
1 parent 5ac1566 commit c2ee1c0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 118 deletions.
56 changes: 0 additions & 56 deletions repos/base-fiasco/include/base/cancelable_lock.h

This file was deleted.

6 changes: 3 additions & 3 deletions repos/base-fiasco/src/base/lock/lock.cc
Expand Up @@ -26,7 +26,7 @@ using namespace Genode;


Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial)
: _lock(UNLOCKED)
: _state(UNLOCKED), _owner(nullptr)
{
if (initial == LOCKED)
lock();
Expand All @@ -39,7 +39,7 @@ void Cancelable_lock::lock()
* XXX: How to notice cancel-blocking signals issued when being outside the
* 'l4_ipc_sleep' system call?
*/
while (!Genode::cmpxchg(&_lock, UNLOCKED, LOCKED))
while (!Genode::cmpxchg(&_state, UNLOCKED, LOCKED))
if (Fiasco::l4_ipc_sleep(Fiasco::l4_ipc_timeout(0, 0, 500, 0)) != L4_IPC_RETIMEOUT)
throw Genode::Blocking_canceled();
}
Expand All @@ -48,5 +48,5 @@ void Cancelable_lock::lock()
void Cancelable_lock::unlock()
{
Genode::memory_barrier();
_lock = UNLOCKED;
_state = UNLOCKED;
}
56 changes: 0 additions & 56 deletions repos/base-sel4/include/base/cancelable_lock.h

This file was deleted.

6 changes: 3 additions & 3 deletions repos/base-sel4/src/base/lock/lock.cc
Expand Up @@ -23,7 +23,7 @@ using namespace Genode;


Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial)
: _lock(UNLOCKED)
: _state(UNLOCKED), _owner(nullptr)
{
if (initial == LOCKED)
lock();
Expand All @@ -32,13 +32,13 @@ Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial)

void Cancelable_lock::lock()
{
while (!Genode::cmpxchg(&_lock, UNLOCKED, LOCKED))
while (!Genode::cmpxchg(&_state, UNLOCKED, LOCKED))
seL4_Yield();
}


void Cancelable_lock::unlock()
{
Genode::memory_barrier();
_lock = UNLOCKED;
_state = UNLOCKED;
}

0 comments on commit c2ee1c0

Please sign in to comment.