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:
Christian Helmuth 2014-04-30 16:30:40 +02:00 committed by Norman Feske
parent 8366d07082
commit de0a771fae
6 changed files with 42 additions and 9 deletions

View File

@ -15,7 +15,6 @@
#define _INCLUDE__BASE__CANCELABLE_LOCK_H_
#include <base/lock_guard.h>
#include <base/native_types.h>
#include <base/blocking.h>
namespace Genode {
@ -33,7 +32,7 @@ namespace Genode {
/**
* Constructor
*/
Cancelable_lock(State initial = UNLOCKED);
explicit Cancelable_lock(State initial = UNLOCKED);
/**
* Try to aquire lock an block while lock is not free

View 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_ */

View File

@ -15,6 +15,7 @@
/* Genode includes */
#include <util/construct_at.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()->entry();
Thread_base::myself()->_join_lock.unlock();
Lock sleep_forever_lock(Lock::LOCKED);
sleep_forever_lock.lock();
sleep_forever();
}

View File

@ -1,11 +1,12 @@
/*
* \brief Lay back and relax
* \author Norman Feske
* \author Christian Helmuth
* \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
* under the terms of the GNU General Public License version 2.
@ -14,15 +15,14 @@
#ifndef _INCLUDE__BASE__SLEEP_H_
#define _INCLUDE__BASE__SLEEP_H_
#include <base/ipc.h>
#include <base/lock.h>
namespace Genode {
__attribute__((noreturn)) inline void sleep_forever()
{
Msgbuf<16> buf;
Ipc_server s(&buf, &buf);
while (1) s >> IPC_WAIT;
Lock sleep;
while (true) sleep.lock();
}
}

View File

@ -14,6 +14,7 @@
#ifndef _INCLUDE__PLATFORM__PBXA9__PL011_DEFS_H_
#define _INCLUDE__PLATFORM__PBXA9__PL011_DEFS_H_
#include <base/stdint.h>
#include <drivers/board_base.h>
enum {

View File

@ -14,6 +14,8 @@
#ifndef _INCLUDE__PLATFORM__VPB926__PL011_DEFS_H_
#define _INCLUDE__PLATFORM__VPB926__PL011_DEFS_H_
#include <base/stdint.h>
#warning pl011 untested on vpb926
enum {