mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Forward compatbility with the kthread branch.
This commit is contained in:
parent
92c5533820
commit
bd489eb73a
3 changed files with 125 additions and 0 deletions
|
@ -94,6 +94,7 @@ log.o \
|
|||
utf8.o \
|
||||
calltrace.o \
|
||||
$(CPU)/calltrace.o \
|
||||
kthread.o \
|
||||
panic.o \
|
||||
keyboard.o \
|
||||
kb/ps2.o \
|
||||
|
|
66
sortix/include/sortix/kernel/kthread.h
Normal file
66
sortix/include/sortix/kernel/kthread.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*******************************************************************************
|
||||
|
||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2012.
|
||||
|
||||
This file is part of Sortix.
|
||||
|
||||
Sortix is free software: you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
Sortix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
kthread.h
|
||||
Fake header providing noop threading functions. This is simply forward
|
||||
compatibility with the upcoming kthread branch and to ease merging.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef SORTIX_KTHREAD_H
|
||||
#define SORTIX_KTHREAD_H
|
||||
|
||||
#warning Using noop kthread functions
|
||||
|
||||
namespace Sortix {
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
class ScopedLock
|
||||
{
|
||||
public:
|
||||
ScopedLock(kthread_mutex_t* mutex)
|
||||
{
|
||||
this->mutex = mutex;
|
||||
kthread_mutex_lock(mutex);
|
||||
}
|
||||
|
||||
~ScopedLock()
|
||||
{
|
||||
kthread_mutex_unlock(mutex);
|
||||
}
|
||||
|
||||
private:
|
||||
kthread_mutex_t* mutex;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Sortix
|
||||
|
||||
#endif
|
||||
|
58
sortix/kthread.cpp
Normal file
58
sortix/kthread.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*******************************************************************************
|
||||
|
||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2012.
|
||||
|
||||
This file is part of Sortix.
|
||||
|
||||
Sortix is free software: you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation, either version 3 of the License, or (at your option) any later
|
||||
version.
|
||||
|
||||
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
Sortix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
kthread.cpp
|
||||
Fake header providing noop threading functions. This is simply forward
|
||||
compatibility with the upcoming kthread branch and to ease merging.
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#include <sortix/kernel/platform.h>
|
||||
#include <sortix/kernel/kthread.h>
|
||||
|
||||
namespace Sortix {
|
||||
|
||||
// This isn't as bad as it looks. Kernel code traditionally runs with interrupts
|
||||
// disabled so there are no race conditions.
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace Sortix
|
Loading…
Add table
Reference in a new issue