summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-29 10:55:29 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-29 11:19:04 +0200
commitc59fdcc021f2c57a6619f4dbc2bb9948bb6bf31c (patch)
treea8b2b9d281a59b13bc0ff957e5699745e7e3a1b1
parent5ded77df39e816f565b26761624893d085ca6eef (diff)
downloadserenity-c59fdcc021f2c57a6619f4dbc2bb9948bb6bf31c.zip
Kernel: Move Lock code out-of-line.
It's so big and chunky anyway, it's silly to expand it everywhere. This makes it a lot easier to read function disassembly dumps.
-rw-r--r--Kernel/Lock.h68
-rw-r--r--Kernel/Makefile1
2 files changed, 1 insertions, 68 deletions
diff --git a/Kernel/Lock.h b/Kernel/Lock.h
index 0341ed3f30..755edf503e 100644
--- a/Kernel/Lock.h
+++ b/Kernel/Lock.h
@@ -56,74 +56,6 @@ private:
Lock& m_lock;
};
-[[gnu::always_inline]] inline void Lock::lock()
-{
- if (!are_interrupts_enabled()) {
- kprintf("Interrupts disabled when trying to take Lock{%s}\n", m_name);
- dump_backtrace();
- hang();
- }
- ASSERT(!Scheduler::is_active());
- for (;;) {
- if (CAS(&m_lock, 1, 0) == 0) {
- if (!m_holder || m_holder == current) {
- m_holder = current;
- ++m_level;
- memory_barrier();
- m_lock = 0;
- return;
- }
- m_lock = 0;
- }
- Scheduler::donate_to(m_holder, m_name);
- }
-}
-
-inline void Lock::unlock()
-{
- for (;;) {
- if (CAS(&m_lock, 1, 0) == 0) {
- ASSERT(m_holder == current);
- ASSERT(m_level);
- --m_level;
- if (m_level) {
- memory_barrier();
- m_lock = 0;
- return;
- }
- m_holder = nullptr;
- memory_barrier();
- m_lock = 0;
- return;
- }
- Scheduler::donate_to(m_holder, m_name);
- }
-}
-
-inline bool Lock::unlock_if_locked()
-{
- for (;;) {
- if (CAS(&m_lock, 1, 0) == 0) {
- if (m_level == 0) {
- memory_barrier();
- m_lock = 0;
- return false;
- }
- ASSERT(m_holder == current);
- ASSERT(m_level);
- --m_level;
- if (m_level) {
- memory_barrier();
- m_lock = 0;
- return false;
- }
- m_holder = nullptr;
- memory_barrier();
- m_lock = 0;
- return true;
- }
- }
-}
#define LOCKER(lock) Locker locker(lock)
diff --git a/Kernel/Makefile b/Kernel/Makefile
index 65325a1ad0..9dcccc2ef4 100644
--- a/Kernel/Makefile
+++ b/Kernel/Makefile
@@ -4,6 +4,7 @@ KERNEL_OBJS = \
init.o \
kmalloc.o \
StdLib.o \
+ Lock.o \
Arch/i386/CPU.o \
Process.o \
SharedBuffer.o \