Commit Graph

19 Commits

Author SHA1 Message Date
Jonas 'Sortie' Termansen 3154492dcf Fix deadlocks and lost wakeups in threading primitives.
The futex and kutex implementations used the same linked list for waiting,
however the futex implementation used kutexs and the same thread could be in
the same list twice in the case of contention. This case corrupted the wait
lists and led to deadlocks and lost wakeups. This change fixes the problem
by having separate data structures for futexes and kutexes.

Mutexes contended by multiple threads could lead to lost wakeups since only
one contended thread was awoken and subsequent unlocks are unaware of the
unawakened contended threads. This change fixes the problem with a temporary
solution of waking all the contended threads until a better design is
implemented.

Additional details are tweaked to be more reliable and simpler.
2022-12-10 21:29:23 +01:00
Jonas 'Sortie' Termansen 5e7605fad2 Implement threading primitives that truly sleep.
The idle thread is now actually run when the system is idle because it
truly goes idle. The idle thread is made power efficient by using the hlt
instruction rather than a busy loop.

The new futex(2) system call is used to implement fast user-space mutexes,
condition variables, and semaphores. The same backend and design is used as
kutexes for truly sleeping kernel mutexes and condition variables.

The new exit_thread(2) flag EXIT_THREAD_FUTEX_WAKE wakes a futex.

Sleeping on clocks in the kernel now uses timers for true sleep.

The interrupt worker thread now truly sleeps when idle.

Kernel threads are now named.

This is a compatible ABI change.
2021-06-23 22:10:47 +02:00
Jonas 'Sortie' Termansen 9f1965f36e Prioritize the interrupt worker thread. 2017-05-18 22:40:46 +02:00
Pedro Falcato 205a3e7156
Remove not_rsp and not_esp. 2016-10-30 12:03:47 +00:00
Jonas 'Sortie' Termansen ecfe121a8c Add assertions to Signal::DispatchHandler callers. 2016-03-28 17:37:37 +02:00
Jonas 'Sortie' Termansen 2b72262b4f Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.

All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.

All imported code from other projects is compatible with this license.

All GPL licensed code from other projects had previously been removed.

Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-05 22:21:50 +01:00
Jonas 'Sortie' Termansen dad5c57f33 Allow bootloader bitmap framebuffer modesetting. 2016-01-08 19:56:11 +01:00
Jonas 'Sortie' Termansen 0045f18c81 Remove kernel Scheduler::Init(). 2015-12-12 19:28:07 +01:00
Jonas 'Sortie' Termansen 12b5044bc7 Fix signal delivery during context switch. 2015-10-09 16:17:52 +02:00
Jonas 'Sortie' Termansen ba1e0882ec Initialize system call table at compile time. 2014-12-03 14:19:49 +01:00
Jonas 'Sortie' Termansen 4c78239721 Implement yielding a timeslice to another thread. 2014-12-02 21:15:08 +01:00
Jonas 'Sortie' Termansen 25e07a9083 Refactor kernel interrupt and thread register support. 2014-11-18 20:33:21 +01:00
Jonas 'Sortie' Termansen 933720e0b0 Remove obsolete system calls. 2014-09-25 17:49:02 +02:00
Jonas 'Sortie' Termansen 8c2befc140 Clean up scheduler. 2014-08-24 14:02:42 +02:00
Jonas 'Sortie' Termansen 30cd318c17 Implement signals.
Note: This is an incompatible ABI change.
2014-07-22 13:25:39 +02:00
Jonas 'Sortie' Termansen f332cf96d4 Add sched_yield(2). 2014-05-29 17:16:49 +02:00
Jonas 'Sortie' Termansen 1f72c1637c Maintain fsbase and gsbase as per-thread registers.
Note: This is an incompatible ABI change.
2014-05-29 17:07:42 +02:00
Jonas 'Sortie' Termansen a133a7717e Refactor i386 and x86_64 interrupt support. 2014-03-17 19:22:13 +01:00
Jonas 'Sortie' Termansen 98a87fa1e5 Rename Sortix kernel directory to kernel. 2014-03-01 14:37:39 +01:00
Renamed from sortix/scheduler.cpp (Browse further)