Kernel: Create RecursiveSpinLock and add it to Process
We now lock every function within Proccess, just to be sure. Recursive lock allows us to use lock from the same thread even if we already have the spinlock locked
This commit is contained in:
@@ -61,7 +61,7 @@ namespace Kernel
|
||||
|
||||
BAN::Vector<OpenFileDescription> m_open_files;
|
||||
|
||||
mutable SpinLock m_lock;
|
||||
mutable RecursiveSpinLock m_lock;
|
||||
|
||||
pid_t m_pid = 0;
|
||||
BAN::String m_working_directory;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <BAN/NoCopyMove.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
@@ -20,4 +22,21 @@ namespace Kernel
|
||||
int m_lock = 0;
|
||||
};
|
||||
|
||||
class RecursiveSpinLock
|
||||
{
|
||||
BAN_NON_COPYABLE(RecursiveSpinLock);
|
||||
BAN_NON_MOVABLE(RecursiveSpinLock);
|
||||
|
||||
public:
|
||||
RecursiveSpinLock() = default;
|
||||
void lock();
|
||||
void unlock();
|
||||
bool is_locked() const;
|
||||
|
||||
private:
|
||||
pid_t m_locker = 0;
|
||||
uint32_t m_lock_depth = 0;
|
||||
SpinLock m_lock;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user