mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Updated the kthread compatibility layer with signal support.
This commit is contained in:
parent
c39473157a
commit
e7baf6a4b0
2 changed files with 49 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
|
||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2012.
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2012.
|
||||
|
||||
This file is part of Sortix.
|
||||
|
||||
|
@ -26,20 +26,27 @@
|
|||
#ifndef SORTIX_KTHREAD_H
|
||||
#define SORTIX_KTHREAD_H
|
||||
|
||||
#define GOT_FAKE_KTHREAD
|
||||
#warning Using noop kthread functions
|
||||
|
||||
namespace Sortix {
|
||||
|
||||
extern "C" {
|
||||
|
||||
typedef unsigned kthread_mutex_t;
|
||||
const kthread_mutex_t KTHREAD_MUTEX_INITIALIZER = 0;
|
||||
extern "C" unsigned kthread_mutex_trylock(kthread_mutex_t* mutex);
|
||||
extern "C" void kthread_mutex_lock(kthread_mutex_t* mutex);
|
||||
extern "C" void kthread_mutex_unlock(kthread_mutex_t* mutex);
|
||||
unsigned kthread_mutex_trylock(kthread_mutex_t* mutex);
|
||||
void kthread_mutex_lock(kthread_mutex_t* mutex);
|
||||
unsigned long kthread_mutex_lock_signal(kthread_mutex_t* mutex);
|
||||
void kthread_mutex_unlock(kthread_mutex_t* mutex);
|
||||
typedef unsigned kthread_cond_t;
|
||||
const kthread_cond_t KTHREAD_COND_INITIALIZER = 0;
|
||||
extern "C" void kthread_cond_wait(kthread_cond_t* cond, kthread_mutex_t* mutex);
|
||||
extern "C" void kthread_cond_signal(kthread_cond_t* cond);
|
||||
extern "C" void kthread_cond_broadcast(kthread_cond_t* cond);
|
||||
void kthread_cond_wait(kthread_cond_t* cond, kthread_mutex_t* mutex);
|
||||
unsigned long kthread_cond_wait_signal(kthread_cond_t* cond, kthread_mutex_t* mutex);
|
||||
void kthread_cond_signal(kthread_cond_t* cond);
|
||||
void kthread_cond_broadcast(kthread_cond_t* cond);
|
||||
|
||||
} // extern "C"
|
||||
|
||||
class ScopedLock
|
||||
{
|
||||
|
@ -60,6 +67,29 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class ScopedLockSignal
|
||||
{
|
||||
public:
|
||||
ScopedLockSignal(kthread_mutex_t* mutex)
|
||||
{
|
||||
this->mutex = mutex;
|
||||
this->acquired = kthread_mutex_lock_signal(mutex);
|
||||
}
|
||||
|
||||
~ScopedLockSignal()
|
||||
{
|
||||
if ( acquired )
|
||||
kthread_mutex_unlock(mutex);
|
||||
}
|
||||
|
||||
bool IsAcquired() { return acquired; }
|
||||
|
||||
private:
|
||||
kthread_mutex_t* mutex;
|
||||
bool acquired;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Sortix
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*******************************************************************************
|
||||
|
||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2012.
|
||||
Copyright(C) Jonas 'Sortie' Termansen 2012.
|
||||
|
||||
This file is part of Sortix.
|
||||
|
||||
|
@ -39,6 +39,11 @@ extern "C" void kthread_mutex_lock(kthread_mutex_t* mutex)
|
|||
{
|
||||
}
|
||||
|
||||
unsigned long kthread_mutex_lock_signal(kthread_mutex_t* mutex)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern "C" void kthread_mutex_unlock(kthread_mutex_t* mutex)
|
||||
{
|
||||
}
|
||||
|
@ -47,6 +52,12 @@ extern "C" void kthread_cond_wait(kthread_cond_t* cond, kthread_mutex_t* mutex)
|
|||
{
|
||||
}
|
||||
|
||||
extern "C" unsigned long kthread_cond_wait_signal(kthread_cond_t* cond,
|
||||
kthread_mutex_t* mutex)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern "C" void kthread_cond_signal(kthread_cond_t* cond)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue