mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-12 05:55:37 +00:00
Generic sleep_forever() based on lock
The old implementation of sleep_forever() used a local Ipc_server object, which is not announced (i.e., known) outside of the blocking process/thread, to infinitely wait for incoming messages. In past and present, this leads to problems (e.g., issues #538 and #1032). Fixes #1135. Fixes #538. Fixes #1032.
This commit is contained in:
parent
8366d07082
commit
de0a771fae
@ -15,7 +15,6 @@
|
|||||||
#define _INCLUDE__BASE__CANCELABLE_LOCK_H_
|
#define _INCLUDE__BASE__CANCELABLE_LOCK_H_
|
||||||
|
|
||||||
#include <base/lock_guard.h>
|
#include <base/lock_guard.h>
|
||||||
#include <base/native_types.h>
|
|
||||||
#include <base/blocking.h>
|
#include <base/blocking.h>
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
@ -33,7 +32,7 @@ namespace Genode {
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Cancelable_lock(State initial = UNLOCKED);
|
explicit Cancelable_lock(State initial = UNLOCKED);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to aquire lock an block while lock is not free
|
* Try to aquire lock an block while lock is not free
|
||||||
|
31
base-fiasco/include/base/sleep.h
Normal file
31
base-fiasco/include/base/sleep.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* \brief Lay back and relax
|
||||||
|
* \author Norman Feske
|
||||||
|
* \author Christian Helmuth
|
||||||
|
* \date 2006-07-19
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2006-2014 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU General Public License version 2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _INCLUDE__BASE__SLEEP_H_
|
||||||
|
#define _INCLUDE__BASE__SLEEP_H_
|
||||||
|
|
||||||
|
/* L4/Fiasco includes */
|
||||||
|
namespace Fiasco {
|
||||||
|
#include <l4/sys/ipc.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Genode {
|
||||||
|
|
||||||
|
__attribute__((noreturn)) inline void sleep_forever()
|
||||||
|
{
|
||||||
|
while (true) Fiasco::l4_ipc_sleep((Fiasco::l4_timeout_t){0});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _INCLUDE__BASE__SLEEP_H_ */
|
@ -15,6 +15,7 @@
|
|||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <util/construct_at.h>
|
#include <util/construct_at.h>
|
||||||
#include <base/thread.h>
|
#include <base/thread.h>
|
||||||
|
#include <base/sleep.h>
|
||||||
|
|
||||||
|
|
||||||
/*****************************
|
/*****************************
|
||||||
@ -54,6 +55,5 @@ void Genode::Thread_base::_thread_start()
|
|||||||
Thread_base::myself()->_thread_bootstrap();
|
Thread_base::myself()->_thread_bootstrap();
|
||||||
Thread_base::myself()->entry();
|
Thread_base::myself()->entry();
|
||||||
Thread_base::myself()->_join_lock.unlock();
|
Thread_base::myself()->_join_lock.unlock();
|
||||||
Lock sleep_forever_lock(Lock::LOCKED);
|
sleep_forever();
|
||||||
sleep_forever_lock.lock();
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* \brief Lay back and relax
|
* \brief Lay back and relax
|
||||||
* \author Norman Feske
|
* \author Norman Feske
|
||||||
|
* \author Christian Helmuth
|
||||||
* \date 2006-07-19
|
* \date 2006-07-19
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2006-2013 Genode Labs GmbH
|
* Copyright (C) 2006-2014 Genode Labs GmbH
|
||||||
*
|
*
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
* under the terms of the GNU General Public License version 2.
|
* under the terms of the GNU General Public License version 2.
|
||||||
@ -14,15 +15,14 @@
|
|||||||
#ifndef _INCLUDE__BASE__SLEEP_H_
|
#ifndef _INCLUDE__BASE__SLEEP_H_
|
||||||
#define _INCLUDE__BASE__SLEEP_H_
|
#define _INCLUDE__BASE__SLEEP_H_
|
||||||
|
|
||||||
#include <base/ipc.h>
|
#include <base/lock.h>
|
||||||
|
|
||||||
namespace Genode {
|
namespace Genode {
|
||||||
|
|
||||||
__attribute__((noreturn)) inline void sleep_forever()
|
__attribute__((noreturn)) inline void sleep_forever()
|
||||||
{
|
{
|
||||||
Msgbuf<16> buf;
|
Lock sleep;
|
||||||
Ipc_server s(&buf, &buf);
|
while (true) sleep.lock();
|
||||||
while (1) s >> IPC_WAIT;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#ifndef _INCLUDE__PLATFORM__PBXA9__PL011_DEFS_H_
|
#ifndef _INCLUDE__PLATFORM__PBXA9__PL011_DEFS_H_
|
||||||
#define _INCLUDE__PLATFORM__PBXA9__PL011_DEFS_H_
|
#define _INCLUDE__PLATFORM__PBXA9__PL011_DEFS_H_
|
||||||
|
|
||||||
|
#include <base/stdint.h>
|
||||||
#include <drivers/board_base.h>
|
#include <drivers/board_base.h>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#ifndef _INCLUDE__PLATFORM__VPB926__PL011_DEFS_H_
|
#ifndef _INCLUDE__PLATFORM__VPB926__PL011_DEFS_H_
|
||||||
#define _INCLUDE__PLATFORM__VPB926__PL011_DEFS_H_
|
#define _INCLUDE__PLATFORM__VPB926__PL011_DEFS_H_
|
||||||
|
|
||||||
|
#include <base/stdint.h>
|
||||||
|
|
||||||
#warning pl011 untested on vpb926
|
#warning pl011 untested on vpb926
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user