#
efbeada7 |
|
21-Aug-2023 |
Jérôme Duval <jerome.duval@gmail.com> |
gnu: add sched_getcpu() on x86_64 implemented with rdtscp or rdpid, generically with a syscall. Change-Id: I8f776848bf35575abec8a8c612c4a25d8550daea Reviewed-on: https://review.haiku-os.org/c/haiku/+/6866 Reviewed-by: waddlesplash <waddlesplash@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
|
#
2d43eebc |
|
04-Aug-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Store "next" pointer before notifying B_EVENT_INVALID. Once B_EVENT_INVALID has been set, the select routine is free to delete the select_info at any time. We therefore cannot access the "next" pointer after notify_select_events returns. May fix a KDL seen by trungnt2910.
|
#
f66d2b46 |
|
26-Jul-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Add event queue implementation to wait for objects efficiently. Based on hamishm's original patch from 2015, but heavily modified, refactored, and reworked. From the original commit message: > When an object is deleted, a B_EVENT_INVALID event is delivered, > and the object is unregistered from the queue. > > The special event flag B_EVENT_ONE_SHOT can be passed in when adding > an object so that the object is automatically unregistered when an > event is delivered. Modifications to the original change include: * Removed the public interface (syscalls remain private for the moment) * Event list queueing/dequeueing almost entirely rewritten, including: - Clear events field when dequeueing. - Have B_EVENT_QUEUED actually indicate whether the event has been appended to the linked list (or not), based around lock state. The previous logic was prone to races and double-insertions. - "Modify" is now just "Deselect + Select" performed at once; previously it could cause use-after-frees. - Unlock for deselect only once at the end of dequeue. - Handle INVALID events still in the queue upon destruction, fixing memory leaks. * Deduplified code with wait_for_objects. * Use of C++ virtual dispatch instead of C-style enum + function calls, and BReferenceable plus destructors for teardown. * Removed select/modify/delete flags. Select/Modify are now the same operation on the syscall interface, and "Delete" is done when 0 is passed for "events". Additionally, the events selected can be fetched by passing -1 for "events". * Implemented level-triggered mode. * Use of BStackOrHeapArray and other convenience routines in syscalls. Change-Id: I1d2f094fd981c95215a59adbc087523c7bbbe40b Reviewed-on: https://review.haiku-os.org/c/haiku/+/6745 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
|
#
1f2e9ca2 |
|
24-Jun-2023 |
Niels Sascha Reedijk <niels.reedijk@gmail.com> |
kernel: ignore overflow warnings in teams.cpp and threads.cpp GCC's overflow checker gives a warning about the potential that the atomic functions called in teams.cpp and threads.cpp will write to a null-pointer. In this case, it is safe to assume that the values will never be null, therefore these warnings can be safely ignored. Relates to/fixes #17734 Change-Id: I777ff96f2812ed7d3ba57a46cad89ef6994cb08f Reviewed-on: https://review.haiku-os.org/c/haiku/+/6643 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
|
#
6554d744 |
|
13-Jun-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Print the first 4 chars of cvar names in KDL "threads" command. Condition variables are now a pretty common way the kernel blocks threads. That means the "threads" command was getting difficult to navigate, since at any given time, a lot of threads could be blocked on "cvar". Now we try (carefully, because it could fault!) to fetch the first 4 characters of the "type" name and display then. This suffices to distinguish the most common object block types in the list at a glance (e.g. "cvar:port" for port reads, the most common.) Change-Id: I94f4b59fd78b7ebdce913944551a5e98f0ca2e33 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6605 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
557f0446 |
|
26-Apr-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Introduce THREAD_BLOCK_TYPE_OTHER_OBJECT. THREAD_BLOCK_TYPE_OTHER implies the "object" pointer in the wait information is a string. But sometimes we want to pass through objects which are not strings, for inspection in KDL.
|
#
d86a240a |
|
29-Mar-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/thread: Refactor thread-local-storage initialization and updating. * TLS slots are not in any way architecture-specific; we do not even have a mechanism by which they could be made so at present. Thus, the initialization of them can be moved to common code, and out of the per-architecture implementations. * When dealing with a fork()ed thread, it will already have a TLS array with values set in it. Therefore, do not overwrite the whole array, but instead only update the specific values which have changed on fork. This fixes at least part of #17896.
|
#
d9694912 |
|
13-May-2022 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Have wait_for_thread fail with EDEADLK when the current thread is specified. This behavior is not required by POSIX (for pthread_join), but it is recommended and other OSes seem to implement it. This constitutes a behavioral change from BeOS, which just deadlocked as we do before this commit (I checked.) Preserving this behavior does not seem very useful, though if in the future we need to, adding a check to libroot is easy enough. This fixes a deadlock encountered when the usb_rndis driver is unplugged; the network stack has a removal path that invokes wait_for_thread on the receive thread, but the function can itself be called from the receive thread. Change-Id: Id3639d98a513f2b0f0bacc90d8d27abb5078857b Reviewed-on: https://review.haiku-os.org/c/haiku/+/5310 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
914b10c1 |
|
11-Mar-2022 |
Jessica Hamilton <jessica.l.hamilton@gmail.com> |
wait_for_thread_etc: expose as syscall/make public. * This will be needed for the following commit that implements `pthread_tryjoin_np` and `pthread_timedjoin_np`. Change-Id: Idccb1aa588d6d10825294d14925d9bd046b65f19 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5098 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Jérôme Duval <jerome.duval@gmail.com> Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|
#
057fe191 |
|
01-Sep-2021 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Break thread-related AutoLockers into a separate header. Including thread.h brings a massive array of things with it from the kernel thread arch headers, team and thread definitions, hash tables, linked lists, Referenceable, etc. that the vast majority of AutoLock.h consumers neither want nor need. So, put these in a separate header, and adjust all consumers of these lockers to include the new file. This change exposes the fact that a lot of files were inadvertently making use of headers included indirectly through thread.h. Those will be fixed in the next commit.
|
#
29536a23 |
|
10-Jan-2021 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel/thread: restore signal mask just before returning to userland * otherwise the signal to be handled might be blocked. fixes #15193 * also remove automatic syscall restart on _kern_select, to match Linux and BSDs behavior: this fixes parallel build with newer gnu make, which happens to use pselect. * also remove automatic syscall restart on _kern_poll. from https://man7.org/linux/man-pages/man7/signal.7.html "The following interfaces are never restarted after being interrupted by a signal handler, regardless of the use of SA_RESTART; they always fail with the error EINTR when interrupted by a signal handler: ... select(2), and pselect(2)." from https://notes.shichao.io/unp/ch6/ "Berkeley-derived kernels never automatically restart select." Change-Id: I3e9488f60c966b38d427f992f06e6e2217d4adc5 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3636 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com> Reviewed-by: Axel Dörfler <axeld@pinc-software.de>
|
#
6ff344d7 |
|
16-Jan-2021 |
Jérôme Duval <jerome.duval@gmail.com> |
Revert "kernel/thread: restore signal mask just before returning to userland" This reverts commit 837f4f48db2f543c730f30d374ec65c7d44c9644. Reason for revert: breaks DNS resolution Change-Id: If6f2a0f60dbfb24121616a9f3879ce226ea4a09a Reviewed-on: https://review.haiku-os.org/c/haiku/+/3519 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
|
#
837f4f48 |
|
10-Jan-2021 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel/thread: restore signal mask just before returning to userland * otherwise the signal to be handled might be blocked. fixes #15193 * also remove automatic syscall restart on _kern_select, to match Linux and BSDs behavior: this fixes parallel build with newer gnu make, which happens to use pselect. * also remove automatic syscall restart on _kern_poll. from https://man7.org/linux/man-pages/man7/signal.7.html "The following interfaces are never restarted after being interrupted by a signal handler, regardless of the use of SA_RESTART; they always fail with the error EINTR when interrupted by a signal handler: ... select(2), and pselect(2)." from https://notes.shichao.io/unp/ch6/ "Berkeley-derived kernels never automatically restart select." Change-Id: I7f86d221eae1ad93d8a308a75581d2c30a369c9e Reviewed-on: https://review.haiku-os.org/c/haiku/+/3627 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
d12e6085 |
|
09-Jan-2021 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel/thread: handle invalid user_thread pointer in user_[un]block_thread should help with #16736 Change-Id: I103488679b8c352855fbd19405bb30c978cf4457 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3613 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
331889d0 |
|
28-Aug-2020 |
Niels Sascha Reedijk <niels.reedijk@gmail.com> |
Kernel/Threads: remove limit on number of dead threads in a team When a thread is created, it is expected that some other thread (usually the creating thread) will want to make sure it completes. This is done using the pthread_join() or wait_for_thread() calls. It is possible that threads end before another thread waits for its completion. That's why there is a dead thread list for each team, which holds thread ids and their exit status so that a call to pthread_join() or wait_for_thread() in the future can complete succesfully. The dead thread list was limited to 32 threads per team. If there would be more, the oldest thread would be kicked off. This could cause issues in situations where a team would create more than 32 threads, and would start waiting for their result after they have finished. Some of the calls would fail because the threads would no longer be in the dead list. This specifically caused problems for cargo (the Rust package manager), which could depending on the number of dependencies, could create more than 32 threads. See: https://github.com/nielx/rust/issues/3 This change removes the limit of dead threads within a team. Note that there is a risk that a badly written program that does not detach or joins its threads can make this an endless list, but the impact is relatively small (dead threads only occupy a bit of kernel memory). Change-Id: I0135dd54e10ee48a529f23228d21237d4f1a74e2 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3178 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|
#
e65c8dea |
|
13-Jun-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/thread: Fix team double lock when reaching thread limit. The team is locked for the allocation of the user thread. When the thread limit is reached, the user thread is removed again by team_free_user_thread which internally locks the team, resulting in a double lock. Unlock the teamLocker before calling team_free_user_thread. Amazingly noone seems to ever have hit the thread limit, even though it is currently at an arbitrarily low 4096.
|
#
3cd10d35 |
|
13-Jun-2020 |
Michael Lotz <mmlr@mlotz.ch> |
kernel/thread: Remove outdated comment. The thread limit enforcement was actually implemented back in hrev45811.
|
#
94951269 |
|
05-May-2020 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel/x86_64: AVX support xsave or xsavec are supported. breaks vregs compatibility. change the thread structure object cache alignment to 64 the xsave fpu_state size isn't defined, it is for instance 832 here, thus I picked 1024. Change-Id: I4a0cab0bc42c1d37f24dcafb8259f8ff24a330d2 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2849 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|
#
e315daa9 |
|
13-Sep-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/thread: Clarify permissions checking logic. No functional change intended; but if I missed a case, it will now be caught by the "return false" instead of the "return true", which is a better default.
|
#
925c3a13 |
|
07-Aug-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/thread: Check the proper field to determine if the thread is blocked. Fixes #15234.
|
#
2c588b03 |
|
05-Aug-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Properly separate and handle THREAD_BLOCK_TYPE_USER. Consider this scenario: * A userland thread puts its ID into some structure so that it can be woken up later, sets its wait_status to initiate the begin of the wait, and then calls _user_block_thread. * A second thread finishes whatever task the first thread intended to wait for, reads the ID almost immediately after it was written, and calls _user_unblock_thread. * _user_unblock_thread was called so soon that the first thread is not yet blocked on the _user_block_thread block, but is instead blocked on e.g. the thread's main mutex. * The first thread's thread_block() call returns B_OK. As in this example it was inside mutex_lock, it thinks that it now owns the mutex. * But it doesn't own the mutex, and so (until yesterday) all sorts of mayhem and then a random crash occurs, or (after yesterday) an assert-failure is tripped that the thread does not own the mutex it expected to. The above scenario is not a hypothetical, but is in fact the exact scenario behind the strange panics in #15211. The solution is to only have _user_unblock_thread actually unblock threads that were blocked by _user_block_thread, so I've introduced a new BLOCK_TYPE to differentiate these. While I'm at it, remove the BLOCK_TYPE_USER_BASE, which was never used (and now never will be.) If we want to differentiate different consumers of _user_block_thread for debugging purposes, we should use the currently-unused "object" argument to thread_block, instead of cluttering the relatively-clean block type debugging code with special types. One final note: The race condition which was the case of this bug does not, in fact, imply a deadlock on the part of the rw_lock here. The wait_status is protected by the thread's mutex, which is acquired by both _user_block_thread and _user_unblock_thread, and so if _user_unblock_thread succeeds faster than _user_block_thread can initiate the block, it will just see that wait_status is already <= 0 and return immediately. Fixes #15211.
|
#
633fbcf4 |
|
29-Mar-2019 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel: receive_data and send_data can be called with a NULL buffer. Change-Id: Id2ac496524ad91f2830e8af12925e0e40ca9ab80 Reviewed-on: https://review.haiku-os.org/c/1333 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|
#
13c4bc94 |
|
20-Feb-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Undo changes to pinned threads and blocking. This reverts commit 58ed2965d0362707ca043b365ac1f2e89ee8c789. This reverts commit 055d49b1fd44ba7c450ad40051a2f34f38508b5f. I was mistaken, it is perfectly legal to block a pinned thread. It seems we'll need some other way to detect invalid context switches.
|
#
58ed2965 |
|
19-Feb-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Panic on attempts to block a pinned thread. Preventing "normal" context switches caused by a time interrupt is the primary reason for pinning threads. "thread_block" and friends, however, cause an explicit context switch and will not return until another thread unblocks us. Calling these while a thread is pinned is thus undefined behavior, and so we should just panic in the case anyone attempts to do so.
|
#
c0549008 |
|
17-Feb-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Sanity-check interrupts in snooze(). This didn't trigger any panics on my bare-metal dev install when tested, but it might explain some easily-reproducible hardlocks (i.e. can't even drop to KDL via emergency keys) I was seeing on other machines.
|
#
5796ecc7 |
|
31-Jan-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/thread: Add proper permissions checks. * Add a utility thread_check_permissions(), which takes the target thread, the calling thread, and whether or not this is a "kernel" call, and then returns whether the target thread may be legally modified. * Refactor all calls that operate by sending a signal to the thread into a single thread_send_signal() utility function, which now uses thread_check_permissions() appropriately. * Manually add the permissions checks to other functions as needed. Solves a bunch of decade+-old TODOs.
|
#
568bb7ee |
|
08-Jan-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/thread: Use a rw_spinlock for the sThreadHashLock. On a dual-core system with no other applications but the standard ones running, my standard "compile HaikuDepot with hot disk cache" benchmark shows a consistent ~5% improvement after this patch (~33.7s -> ~31.9s sys). On systems with higher core and thread counts, these numbers are probably very much larger (I'd imagine it could be up to even 10 or 15%.) Change-Id: I5df2a075bae7c71b84c6fcd33ead60df8e844757 Reviewed-on: https://review.haiku-os.org/c/861 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
e6bb3453 |
|
08-Jan-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/thread: Properly implement has_data for non-current threads. This was left unimplemented since the dawn of Haiku; but it's so rarely used nobody seems to have noticed. I've taken care to leave it optimized for the current thread case. Change-Id: Ib028a37963b2da6d0ca9b4dbd5a5f4a74ecf25b4 Reviewed-on: https://review.haiku-os.org/c/860 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
|
#
7ea987c1 |
|
07-Jan-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Improvements to "resume" KDL command. * Print a message when not resuming a thread because it is running. When I was using this command while working on ipro1000, I assumed that "no news was good news." But it seems that wasn't the case. Hopefully future developers will be less confused after this. * Allow resuming threads that are in "asleep" or "waiting" states, not just in "suspended" state. Presumably a developer poking around in KDL knows what they are doing, so allowing them to do this seems to make sense.
|
#
ee0b0d6d |
|
09-Dec-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Fix typos in documentation. Spotted by Clang (yes, there is a -Wdocumentation that understands how to parse Doxygen comments!)
|
#
aa083651 |
|
24-Nov-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: thread->name is never NULL as it is an array. Spotted by Clang (-Wtautological-pointer-compare.)
|
#
513403d4 |
|
14-Jun-2018 |
Augustin Cavalier <waddlesplash@gmail.com> |
Revert team and thread changes for COMPAT_MODE (hrev52010 & hrev52011). This reverts commit c558f9c8fe54bc14515aa62bac7826271289f0e4. This reverts commit 44f24718b1505e8d9c75e00e59f2f471a79b5f56. This reverts commit a69cb330301c4d697daae57e6019a307f285043e. This reverts commit 951182620e297d10af7fdcfe32f2b04d56086ae9. There have been multiple reports that these changes break mounting NTFS partitions (on all systems, see #14204), and shutting down (on certain systems, see #12405.) Until they can be fixed, they are being backed out.
|
#
a69cb330 |
|
20-May-2018 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel/x86_64: setup a new thread in compatibility mode. * define compat_thread_info, compat_rlim_t, compat_rlimit and compat_thread_creation_attributes to be used when applicable in compatibility mode. * handle 32-bit types in _user_spawn_thread(), _user_get_thread_info(), _user_get_next_thread_info(), _user_getrlimit(), _user_setrlimit(), other syscalls are compatible as is. * init TLS for compatibility mode threads. Change-Id: I483ba95e6198ddac9d240671bcb56fcd2ad831d2
|
#
e1ceb339 |
|
03-Apr-2018 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel: override access control in user_[un]block_thread()... when reading/writing the wait_status in userland. fixes #14067.
|
#
9dd4d2dd |
|
03-Jan-2018 |
Jérôme Duval <jerome.duval@gmail.com> |
kernel: support for Intel SMAP and SMEP on x86_64. SMAP will generated page faults when the kernel tries to access user pages unless overriden. If SMAP is enabled, the override instructions are written where needed in memory with binary "altcodepatches". Support is enabled by default, might be disabled per safemode setting. Change-Id: Ife26cd765056aeaf65b2ffa3cadd0dcf4e273a96
|
#
dbf060a3 |
|
29-Oct-2015 |
Simon South <ssouth@simonsouth.com> |
libroot: Add brk() and sbrk(). This commit replaces the placeholder implementation of sbrk(), which operated on a process' heap, with real implementations of brk() and sbrk() that adjust a process' program break. * unistd.h: Add standard definitions of brk() and sbrk(); include stdint.h for intptr_t. * thread.cpp: Recognize RLIMIT_AS and RLIMIT_DATA resource limits (both currently unlimited); order limit identifiers alphabetically. * arch-specific.cpp: Remove sbrk_hook(). * malloc_debug_api.cpp: Remove sbrk_hook(). * unistd/Jamfile: Build brk.c instead of sbrk.c. * unistd/brk.c: Add. * unistd/sbrk.c: Delete (placeholder implementation). * libroot_stubs.c: Remove sbrk_hook(). * libroot_stubs_legacy.c: Remove sbrk_hook(). * src/tests/.../posix/Jamfile: Build brk_test.c. * brk_test.c: Add (simple unit test that demonstrates behaviour of sbrk()). Signed-off-by: Jérôme Duval <jerome.duval@gmail.com>
|
#
744dfa3c |
|
18-Apr-2014 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: make sure thread priority is within valid range The scheduler expects that all threads expect the initial idle threads have priority in range [THREAD_MIN_SET_PRIORITY, THREAD_MAX_SET_PRIORITY]. If the requested pririty is out of range the value is clamped. Failing with B_BAD_VALUE is probably an overkill since there isn't any real change in the guarantees provided by the scheduler about the behavior of such thread. Also, BeBook suggests that spawn_thread() can specify priority 0.
|
#
e6ea745e |
|
06-Dec-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Use SMP_MAX_CPUS instead of B_MAX_CPU_COUNT
|
#
2b7ea4cd |
|
29-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove Thread::next_state
|
#
673f08a9 |
|
28-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Make thread_block_locked() private
|
#
286b341a |
|
28-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Merge two occurences of thread resume code
|
#
03f7d3d1 |
|
24-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Restore logical processor disabling
|
#
288a2664 |
|
12-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
scheduler: Remove sSchedulerInternalLock * pin idle threads to their specific CPUs * allow scheduler to implement SMP_MSG_RESCHEDULE handler * scheduler_set_thread_priority() reworked * at reschedule: enqueue old thread after dequeueing the new one
|
#
a1feba67 |
|
11-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel/undertaker: Make sure the thread isn't running anymore
|
#
03fb2d88 |
|
07-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove gSchedulerLock * Thread::scheduler_lock protects thread state, priority, etc. * sThreadCreationLock protects thread creation and removal and list of threads in team. * Team::signal_lock and Team::time_lock protect list of threads in team as well. * Scheduler uses its own internal locking.
|
#
72addc62 |
|
07-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Introduce Thread::time_lock and Team::time_lock
|
#
3519eb33 |
|
06-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Change Thread::team_lock to rw_spinlock
|
#
83983eaf |
|
06-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove Thread::alarm
|
#
aa4aca02 |
|
06-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Protect signal data with Team::signal_lock
|
#
11cacd0c |
|
04-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove thread_block_with_timeout_locked()
|
#
c2763aaf |
|
30-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Add spinlock for undertaker data
|
#
d8fcc8a8 |
|
30-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove B_TIMER_ACQUIRE_SCHEDULER_LOCK flag The flag main purpose is to avoid race conditions between event handler and cancel_timer(). However, cancel_timer() is safe even without using gSchedulerLock. If the event is scheduled to happen on other CPU than the CPU that invokes cancel_timer() then cancel_timer() either disables the event before its handler starts executing or waits until the event handler is done. If the event is scheduled on the same CPU that calls cancel_timer() then, since cancel_timer() disables interrupts, the event is either executed before cancel_timer() or when the timer interrupt handler starts running the event is already disabled.
|
#
c8dd9f77 |
|
29-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Add thread_unblock() and use it where possible
|
#
978fc080 |
|
23-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
scheduler: Remove support for running different schedulers Simple scheduler behaves exactly the same as affine scheduler with a single core. Obviously, affine scheduler is more complicated thus introduces greater overhead but quite a lot of multicore logic has been disabled on single core systems in the previous commit.
|
#
7e1ecb93 |
|
23-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Protect scheduler_set_thread_priority() with lock
|
#
ea79da95 |
|
20-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove support for thread_queue
|
#
84812e60 |
|
20-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
scheduler_affine: Correctly assign CPUs to idle threads
|
#
f20ad54b |
|
14-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Add support for SMP systems to simple scheduler In SMP systems simple scheduler will be used only when all logical processors share all levels of cache and the number of CPUs is low. In such systems we do not have to care about cache affinity and the contention on the lock protecting shared run queue is low. Single run queue makes load balancing very simple.
|
#
29e65827 |
|
09-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove possibility to yield to all threads Kernel support for yielding to all (including lower priority) threads has been removed. POSIX sched_yield() remains unchanged. If a thread really needs to yield to everyone it can reduce its priority to the lowest possible and then yield (it will then need to manually return to its prvious priority upon continuing).
|
#
fee80091 |
|
09-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Add another penalty for CPU bound threads Each thread has its minimal priority that depends on the static priority. However, it is still able to starve threads with even lower priority (e.g. CPU bound threads with lower static priority). To prevent this another penalty is introduced. When the minimal priority is reached penalty (count mod minimal_priority) is added, where count is the number of time slices since the thread reached its minimal priority. This prevents starvation of lower priorirt threads (since all CPU bound threads may have their priority temporaily reduced to 1) but preserves relation between static priorities - when there are two CPU bound threads the one with higher static priority would get more CPU time.
|
#
130000e0 |
|
08-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Dump scheduler specific thread data
|
#
0896565a |
|
08-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Support sched_yield() properly sched_yield() should not yield to the threads with lower priority.
|
#
9363e99b |
|
08-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove Thread::next_priority
|
#
03e3a829 |
|
07-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Allow threads to yield CPU properly
|
#
2eb2b522 |
|
01-Jul-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Enforce team and thread limits Also fixes incorrect team accounting in case of error when creating a team. The previously incremented sUsedTeams wasn't decremented again.
|
#
c24adb29 |
|
19-Apr-2013 |
Rene Gollent <anevilyak@gmail.com> |
Rework DefaultNotificationService registration. - Instead of implicitly registering and unregistering a service instance on construction/destruction, DefaultNotificationService now exports explicit Register()/Unregister() calls, which subclasses are expected to call when they're ready. - Adjust all implementing subclasses. Resolves an issue with deadlocks when booting a DEBUG=1 build.
|
#
17c18989 |
|
26-Feb-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
thread: randomize user stack position Use B_RANDOMIZE_BASE_ADDRESS for creating both main and other threads user stack.
|
#
d1f280c8 |
|
01-Apr-2012 |
Hamish Morrison <hamishm53@gmail.com> |
Add support for pthread_attr_get/setguardsize() * Added the aforementioned functions. * create_area_etc() now takes a guard size parameter. * The thread_info::stack_base/end range now refers to the usable range only.
|
#
6912e7dc |
|
23-Aug-2012 |
Edward Robbins <edd.robbins@gmail.com> |
getrlimit with RLIMIT_STACK now returns USER_MAIN_THREAD_STACK_SIZE Signed-off-by: Rene Gollent <anevilyak@gmail.com>
|
#
07c6bd65 |
|
23-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Format string fixes for TRACE_{THREAD,TEAM}.
|
#
c3f0fd28 |
|
12-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Fixed formatting of output in some debugger commands. Currently all debugger commands assume 32-bit pointers when formatting their output. This means that on x86_64 the output is incorrectly formatted. Fixed this by adding a B_PRINTF_POINTER_WIDTH definition (16 on 64-bit, 8 on 32-bit), and using this to correctly format the output. Not all commands have been fixed yet, but all VM, slab, VFS, team, thread and image commands should be correct.
|
#
92284dcc |
|
08-Jul-2012 |
Pawel Dziepak <pdziepak@quarnos.org> |
nfs4: Use semaphore to cancel threads instead of interrupt_thread()
|
#
e552920f |
|
30-May-2012 |
Pawel Dziepak <pdziepak@quarnos.org> |
nfs4: Fix rpc listener thread cancelation recv on UDP sockets is not interrupted when the socket is closed. Additionaly, signals do not interrupt kernel threads, that is why new function interrupt_thread was implemented in order to cancel listener thread.
|
#
294711f9 |
|
27-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Changed {,u}int64 to be long rather than long long on x86_64.
|
#
4be4fc6b |
|
15-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
More 64-bit compilation/safety fixes.
|
#
4bbb27e3 |
|
12-Feb-2012 |
Jerome Duval <jerome.duval@gmail.com> |
More 'GCC4.6 variable set but not used' fixes.
|
#
88520e79 |
|
12-Feb-2012 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
create_thread_user_stack(): Fix incorrect handling of TLS size In case a custom stack was given, the TLS size was subtracted from the stack base, not the stack size.
|
#
62bb3756 |
|
05-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Restructure wait_for_thread_etc() to make it easier to follow. * Avoid needless adding of the death entry if the sem is gone already. * Delete objects as soon as they aren't needed anymore and return early where possible. * Contain the thread == NULL case in its block and return from there as well instead of non-obviously figuring out what happened later. * Pull out the return code asignment. * Minor cleanup.
|
#
da329fc0 |
|
05-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Add missing asignment of return code in wait_for_thread_etc(). While it was detected that the thread is in the destruction phase and that it was necessary to wait and then have a valid status code in the death entry, that status code wasn't actually returned. This lead to uninitialized values for the return code even though wait_for_thread[_etc]() would return B_OK.
|
#
552d9901 |
|
26-Nov-2011 |
Philippe Saint-Pierre <stpere@gmail.com> |
Replace usage of sprintf with snprintf Fixing CID 10964
|
#
fae2ce19 |
|
07-Nov-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Enlarge threads and ports KMessage notification stack buffers They were too small for all the fields added. This is why the system profiler skipped "thread added" notifications. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43216 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
17f2def1 |
|
28-Sep-2011 |
Rene Gollent <anevilyak@gmail.com> |
Only call UserDefinedTimersRemoved if there actually are any. Should fix #7998. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42776 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9437559d |
|
14-Jun-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added function team_init_exit_info_on_error() which initializes the team's exit info with some generic status. * team_create_thread_start(), common_thread_entry(): Initializes the team's exit info (if that's the main thread) before calling thread_exit(). Fixes #7686. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42183 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
24df6592 |
|
11-Jun-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged signals-merge branch into trunk with the following changes: * Reorganized the kernel locking related to threads and teams. * We now discriminate correctly between process and thread signals. Signal handlers have been moved to teams. Fixes #5679. * Implemented real-time signal support, including signal queuing, SA_SIGINFO support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition of the real-time signal range. Closes #1935 and #2695. * Gave SIGBUS a separate signal number. Fixes #6704. * Implemented <time.h> clock and timer support, and fixed/completed alarm() and [set]itimer(). Closes #5682. * Implemented support for thread cancellation. Closes #5686. * Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554. * Lots over smaller more or less related changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
57ceeee4 |
|
26-Feb-2011 |
Jérôme Duval <korli@users.berlios.de> |
copy sig_action structure from the current thread if we're the same team. Helps with #7235 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40701 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4535495d |
|
10-Jan-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged the signals branch into trunk, with these changes: * The team and thread kernel structures have been renamed to Team and Thread respectively and moved into the new BKernel namespace. * Several (kernel add-on) sources have been converted from C to C++ since private kernel headers are included that are no longer C compatible. Changes after merging: * Fixed gcc 2 build (warnings mainly in the scary firewire bus manager). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b734adba |
|
02-Jan-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
find_thread(): thread::name is an array, so the NULL check is useless (CID 4073). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40083 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4ebc8f61 |
|
15-Dec-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added a "name changed" notification to the thread notification service. * Added a "team" field to the notification events. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39861 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
27a115f6 |
|
14-Dec-2010 |
Rene Gollent <anevilyak@gmail.com> |
Revert r39846 and r39847. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39849 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7040b50d |
|
13-Dec-2010 |
Rene Gollent <anevilyak@gmail.com> |
Add support for thread rename and priority change notifications to the debugger API/message set. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39846 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
44db70a3 |
|
15-Jul-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Resolved TODO: Use an object cache for the thread structure alloction. * Align the allocated objects to 16 byte. This is required by the x86 arch_thread structure. Haiku only didn't crash and burn since the until recently used heap allocator apparently aligned the structures to 16 byte anyway and the now used slab allocator has a bug preventing slab coloring for that object size. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37532 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3121f394 |
|
13-Jul-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
thread_exit(): Postpone deleting the thread's user stack until after sending the thread's death notifications. The fixes issues where other threads depend on objects on its stack (particularly relevant for the main thread). Fixes #6315. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37509 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a8ad734f |
|
14-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced structures {virtual,physical}_address_restrictions, which specify restrictions for virtual/physical addresses. * vm_page_allocate_page_run(): - Fixed conversion of base/limit to array indexes. sPhysicalPageOffset was not taken into account. - Takes a physical_address_restrictions instead of base/limit and also supports alignment and boundary restrictions, now. * map_backing_store(), VM[User,Kernel]AddressSpace::InsertArea()/ ReserveAddressRange() take a virtual_address_restrictions parameter, now. They also support an alignment independent from the range size. * create_area_etc(), vm_create_anonymous_area(): Take {virtual,physical}_address_restrictions parameters, now. * Removed no longer needed B_PHYSICAL_BASE_ADDRESS. * DMAResources: - Fixed potential overflows of uint32 when initializing from device node attributes. - Fixed bounce buffer creation TODOs: By using create_area_etc() with the new restrictions parameters we can directly support physical high address, boundary, and alignment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37131 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d3166e46 |
|
29-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Replaced no longer necessary send_signal_etc() work-arounds for resume_thread(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36531 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5a0b30db |
|
06-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Don't cancel the alarm on exec*(). POSIX alarm() requires that. The BeBook doesn't mention the expected set_alarm() behavior. Tests under BeOS R5 Bone crash the system in either case, though, so I guess we're free to go with the expected POSIX behavior. This make detection of hanging tests in the Open POSIX Test Suite work. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36046 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7778bccf |
|
13-Mar-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
sigsuspend() would previously wake up correctly when a matching signal was received, but if the signal was in the thread's signal block mask, it would not be handled. Added thread::sig_temp_enabled, an additional mask of not blocked signals, which is set by sigsuspend() and evaluated and reset by handle_signals(). Fixes #5567. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35836 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
cee04e80 |
|
08-Feb-2010 |
Artur Wyszynski <aljen-mlists@o2.pl> |
Fixed various errors/warnings reported by cppcheck: * memory leaks * resource leaks * added const's to getters * removed a few reundant conditions git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35433 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5662ae45 |
|
20-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Changed the team shutdown process a bit: * The threads beside the main thread are killed earlier now (in the new team_shutdown_team()), before removing the team from the team hash and from its process group. This fixes #5296. * Use a condition variable instead of a semaphore to wait for the non-main threads to die. We notify the condition right after a thread has left the team. The semaphore was released by the undertaker. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35196 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0338371f |
|
13-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* All scheduler implementations: - enqueue_in_run_queue() no longer returns whether rescheduling is supposed to happen. Instead is sets cpu_ent::invoke_scheduler on the current CPU. - reschedule() does now handle cpu_ent::invoke_scheduler_if_idle(). No need to let all callers do that. * thread_unblock[_locked]() no longer return whether rescheduling is supposed to happen. * Got rid of the B_INVOKE_SCHEDULER handling. The interrupt hooks really can't know, when it makes sense to reschedule or not. * Introduced scheduler_reschedule_if_necessary[_locked]() functions for checking+invoking the scheduler. * Some semaphore functions (e.g. delete_sem()) invoke the scheduler now, if they wake up anything with greater priority. I've also tried to add scheduler invocations in the condition variable and mutex/rw_lock code, but that actually has a negative impact on performance, probably because it causes too much ping-ponging between threads when multiple locking primitives are involved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34657 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a195cce7 |
|
12-Dec-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Added a bit more missing info about user_threads. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34647 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b4be7c90 |
|
11-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added cpu_ent::running_thread which is maintained by the schedulers. * simple_smp scheduler: Rewrote the interesting part of enqueue_in_run_queue(). It always selects a target CPU for the inserted thread, now. If no CPU is idle, the CPU running the thread with the lowest priority is chosen. If the thread running on the target CPU has a lower priority than the inserted one, it will be asked to reschedule. If that's the current CPU, we'll return the correct value (wasn't done before at all). These changes help reducing latencies. On my machine in an idle system playing music DebugAnalyzer shows maximum latencies of about 1 us. I still find that a bit much, but it's several orders of magnitude better than before. The -j8 Haiku image build time dropped about 10%. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34635 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3533b659 |
|
10-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Reintroduced the SMP_MSG_RESCHEDULE_IF_IDLE ICI message. This time implemented by means of an additional member in cpu_ent. * Removed thread::keep_scheduled and the related functions. The feature wasn't used yet and wouldn't have worked as implemented anyway. * Resurrected an older, SMP aware version of our simple scheduler and made it the default instead of the affine scheduler. The latter is in no state to be used yet. It causes enormous latencies (I've seen up to 0.1s) even when six or seven CPUs were idle at the same time, totally killing parallelism. That's also the reason why a -j8 build was slower than a -j2. This is no longer the case. On my machine the -j2 build takes about 10% less time now and the -j8 build saves another 20%. The latter is not particularly impressive (compared with Linux), but that seems to be due to lock contention. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34615 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e50cf876 |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved the VM headers into subdirectory vm/. * Renamed vm_cache.h/vm_address_space.h to VMCache.h/VMAddressSpace. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34449 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
90d870c1 |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved VMAddressSpace definition to vm_address_space.h. * "Classified" VMAddressSpace, i.e. turned the vm_address_space_*() functions into methods, made all attributes (but "areas") private, and added accessors. * Also turned the vm.cpp functions vm_area_lookup() and remove_area_from_address_space() into VMAddressSpace methods. The rest of the area management functionality will follow soon. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34447 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8665c30a |
|
07-Nov-2009 |
Michael Lotz <mmlr@mlotz.ch> |
That was not such a good destruction order in the error case. As the scheduler accesses the scheduler data inside the thread structure, freeing it first lead to a crash when a thread couldn't be created. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33940 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6390c0ca |
|
22-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* _get_next_thread_info() should be a bit more picky about its team needs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33741 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3530c3eb |
|
22-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Reimplemented the insane _get_next_thread_info() which previously just iterated over all known thread *IDs* with interrupts disabled. Now it iterates over the team's thread list (going from back to front, since new threads are added at the front of the singly linked queue). * Alexandre restarted Tracker quite a lot, and let the shell script run to reproduce a certain bug - and then wondered why ProcessController would take several seconds to open its windows until it passed through more than 8 million IDs... :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33737 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
68d9d880 |
|
22-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Just use the heap instead of cbuf for send_data(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33722 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ea95b4d0 |
|
14-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Cleanup, no functional change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33580 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
009ccc29 |
|
20-Aug-2009 |
Rene Gollent <anevilyak@gmail.com> |
anevilyak+mmlr: * scheduler_enqueue_in_runqueue() now allows the scheduler to return a hint as to whether a reschedule is desirable or not. This is used in a few other places in order to relegate scheduling decisions entirely to the scheduler rather than the priority hacks previously used. There are probably other places in the kernel that could now make use of that information to more intelligently call reschedule() though. * Switch over the default scheduler to scheduler_affine(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32554 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d3b44ccb |
|
29-Jul-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added explicit physical address parameter to vm_create_anonymous_area() and create_area_etc(). 0 for the default behavior. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31941 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ba391bcc |
|
22-Jun-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added team_debug_info::debugger_changed_condition to serialize changes to the installed team debugger and adjusted the code accordingly. It's not needed yet, but I intend to add support for software breakpoints and those require a bit of uninitialization that needs to be synchronized with debugger changes and can't be done with interrupts disabled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31194 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6ad4a777 |
|
14-Jun-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Also set user_thread to NULL. It shouldn't make a difference, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31040 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
591bc3f2 |
|
28-May-2009 |
Jérôme Duval <korli@users.berlios.de> |
* various fixes identified by gcc4, provided by Joe Prostko git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30902 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
efd536ff |
|
11-Apr-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Cleared up a misconception in the notification mechanism. We already had methods that used an "event mask" field. There was no need to introduce a "flags" field for the same purpose. * Renamed protected DefaultNotificationService methods (removed "_" prefix). * Adjusted the code providing a notification service accordingly. * Changed the event message several notification services generated by renaming the "opcode" field to "event". * Implemented the TEAM_ADDED event and also added a TEAM_EXEC event. * Added notifications for threads and images. * Added visitor-like iteration functions for teams, threads, and images. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30126 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ec29f084 |
|
04-Apr-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
bonefish + mmlr: Don't really resume the undertaker thread after creating it, since at that point the scheduler has not been started yet. Didn't do any harm, since it was only the second thread anyway and the idle thread was rescheduled almost immediately. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29908 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0296b82a |
|
25-Mar-2009 |
Rene Gollent <anevilyak@gmail.com> |
Add several extra scheduler hook functions to allow the scheduler(s) to maintain private housekeeping data on the thread structs. These hooks are called on thread creation/destruction and when prepping a thread for use. Review welcome. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29721 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4c35c6b5 |
|
17-Mar-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* _user_unblock_thread[s]() also set the user thread's wait_status, now. This makes them more convenient to use, since the caller doesn't need to know the target threads' user thread structure. * Adjusted the pthread rwlock implementation accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29578 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c33667d4 |
|
01-Feb-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Fixing warnings under GCC4 in preparation to enable -Werror there as well: * Replaced the use of offsetof() for structs that aren't PODs. Add a offset_of_member() macro to util/khash.h because that's what it's used for in our cases. * Change the signature of add_debugger_command()/remove_debugger_command() on GCC > 2 to avoid the depricated conversion from string constants to char *. * Adding some "suggested" parenthesis. I know that not everyone likes that, but it pointed out at least one bug that is fixed here as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29113 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2c1e463c |
|
05-Nov-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Removed B_{MIN|MAX}_PRIORITY from OS.h - they were never really intended as public defines. They are now called THREAD_{MIN|MAX}_SET_PRIORITY to better reflect what they are for. Minimum priority is now 1, ie. you no longer can set another thread to the idle priority. This fixes part of ticket #2959. * set_thread_priority() will no longer allow to change the priority of the idle thread to something else. This fixes the rest of ticket #2959. * Automatic whitespace cleanup in OS.h. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28521 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
53892c92 |
|
20-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Replaced scheduler_remove_from_run_queue() by scheduler_set_thread_priority(). Setting the thread priority was the only situation in which it was used. * Renamed scheduler.cpp to scheduler_simple.cpp. * The scheduler functions are no longer called directly. Instead there's an operation vector now, which is initialized at kernel init time. This allows for picking the most suitable scheduler for the machine (e.g. a non-SMP scheduler on a non-SMP machine). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28262 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
808de9c7 |
|
17-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* The undertaker was not locking when enqueuing the thread structure in the free queue. * "thread" also prints the thread's I/O priority. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28218 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1e2bc11e |
|
16-Oct-2008 |
François Revol <revol@free.fr> |
bonefish+mmu_man: fix cbuf_user_memcpy_from_chain() returning an error when the source buffer was NULL despite being asked for 0 bytes, while the counterpart was actually not creating a buffer for 0 bytes to send... Also don't bother calling it from receive_data() in that case anyway. This fixes a deadlock in SoundPlay that made it freeze when trying to play the 2nd sound. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28179 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6503e5d9 |
|
11-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added functions to pin a thread to the current CPU (i.e. it will only be scheduled on that CPU) and to avoid unscheduling it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27974 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
74785e79 |
|
07-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added "from" address space parameter to vm_swap_address_space()/ arch_vm_aspace_swap(). * The x86 implementation does now maintain a bit mask per vm_translation_map_arch_info indicating on which CPUs the address space is active. This allows flush_tmap() to avoid ICI for user address spaces when the team isn't currently running on any other CPU. In this context ICI is relatively expensive, particularly since we map most pages via vm_map_page() and therefore invoke flush_tmap() pretty much for every single page. This optimization speeds up a "hello world" compilation about 20% on my machine (KDEBUG turned off, freshly booted), but interestingly it has virtually no effect on the "-j2" haiku build time. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27912 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
032ff97f |
|
06-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
When a thread times out on a locking primitive, reschedule only, if the timed out thread has a higher priority than the currently running one. Maybe we should even restrict this behavior to realtime threads. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27897 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
23884ae0 |
|
19-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Introduced a callback field in the thread structure. It can be set in an interrupt handler and will be executed right before returning from the interrupt. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27648 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
cbcebd33 |
|
15-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Extended the debugger API by sampling-based profiling support. This is still pretty much work in progress. * Introduced init_thread_debug_info() which is used instead of clear_thread_debug_info() when the thread is created. The latter requires former initialization. * user_debug_thread_deleted() is now already invoked in thread_exit(), not in the undertaker. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27531 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c2a59f23 |
|
12-Sep-2008 |
Ryan Leavengood <leavengood@gmail.com> |
Remove the null check as per Axel's advice: valid arguments within the range are never null. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27450 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d1363991 |
|
11-Sep-2008 |
Ryan Leavengood <leavengood@gmail.com> |
Fixed CID 1299: the char* name was used in a call to strtoul on line 1220 before being NULL checked on line 1234. I moved the null check to be after name is initialized and removed it from line 1234. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27428 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
89cfd542 |
|
04-Sep-2008 |
Karsten Heimrich <host.haiku@gmx.de> |
* revert r27322 and apply the patch provided by Salvatore Thanks you! :) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27323 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3b3e3805 |
|
30-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added thread::io_priority field and functions to get/set it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27247 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
07569b03 |
|
22-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added kernel private thread_state_to_text() which just calls state_to_text(). * state_to_text() can now deal with a NULL thread argument. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27163 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
16cfc877 |
|
22-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added option "-s" to the "thread" command, which prints the info in short form (like "threads"). * "thread" allows to specify more than one thread now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27152 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1e906305 |
|
21-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added a "flags" parameter to vm_create_anonymous_area() and create_area_etc(). * When the new flag CREATE_AREA_DONT_WAIT is specified, the functions don't wait for memory or pages to become available. They fail immediately instead. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27117 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3b99126c |
|
12-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed table columns alignment in the "threads" command. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26948 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
57f2b5a0 |
|
05-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed the meaning of the {KERNEL,USER}_STACK_SIZE macros to not include the guard pages. Adjusted the kernel and boot loader code accordingly -- the guard pages size is added/not removed respectively. The stack size passed to _kern_spawn_thread() is now the actually usable size, and it is no longer possible to specify a size smaller than or equal to the guard pages size. * vm_create_anonymous_area(): Precommit two pages maximum -- a stack with only one page usable size obviously doesn't need two pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26819 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a9d458d8 |
|
02-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Also init kernel_stack_top for the idle threads. It was NULL before, which caused stack traces in those threads to crash. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26746 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
15374c5d |
|
02-Aug-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed thread_spinlock and team_spinlock to gThreadSpinlock and gTeamSpinlock. * Renamed the static global variables in smp.c to match our style guide. * Minor other cleanup. * Removed superfluous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26730 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
12c9f176 |
|
31-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added thread block type constant for rw_locks, so that they are listed correctly by the "thread" and "threads" debugger commands. * Added "rwlock" debugger command. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26703 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
736352dc |
|
16-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added [un]lock_memory_etc() versions that accept a team_id as first argument. This allows drivers to lock the memory outside of the original team context. * create_area_etc() got a struct team as first argument, but that should have been a team_id. * Removed delete_area_etc() - there is already vm_delete_area() doing the same thing. * Renamed vm_get_address_space_by_id() to vm_get_address_space(), as there is no other method of getting an address space. * Removed erroneous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26455 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
dc271293 |
|
03-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
stippi + bonefish: * Missing backslash in UPDATE_THREAD_KERNEL_TIME() macro. Caused the thread's kernel time never to be updated when the thread left the kernel. The time would be added to the user time instead. * Changed semantics of thread_at_kernel_exit(). It leaves interrupts disabled when returning, now. All code using it would disable interrupts afterwards anyway, and inbetween the thread could be interrupted causing two more time updates (or actually not causing them erroneously). * The code in x86's interrupt handler entry (int_bottom) also checks thread::in_kernel now, to determine whether the thread was already considered to be in userland. This is necessary since the sysexit instruction doesn't reenable interrupts, so that we have to do that with the preceeding instruction. Hence an interrupt can occur inbetween, which would incorrectly add the interrupt's kernel time to the thread's user time. * For userland threads team_create_thread_start() didn't invoke thread_at_kernel_exit() or any equivalent. We do that in arch_thread_enter_userspace() now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26240 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0cb2617f |
|
01-Jun-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Before starting to wait the undertaker does now check whether there's already a dead thread available. Fixes a race condition. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25754 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1c8de858 |
|
01-Jun-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added optional spinlock contention measurement feature. Enabled when B_DEBUG_SPINLOCK_CONTENTION is defined to 1. It typedefs spinlock to a structure (thus breaking BeOS binary compatibility), containing a counter which is incremented whenever a thread has to wait for the spinlock. * Added macros for spinlock initialization and access and changed code using spinlocks accordingly. This breaks compilation for BeOS -- the macros should be defined in the respective compatibility wrappers. * Added generic syscall to get the spinlock counters for the thread and the team spinlocks. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25752 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
91015353 |
|
29-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added new kernel thread "undertaker" which gets rid of dead thread remains. This replaces the previous mechanism of switching the thread to a dedicated death stack. We might consider moving more cleanup work to the undertaker, but that seems a little more involved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25704 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b5e3c0a1 |
|
12-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added new syscalls _kern_block_thread()/_kern_unblock_thread[s](). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25469 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d648afb8 |
|
11-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* For each userland team the kernel creates an area in the userland address space that is fully locked and marked B_KERNEL_AREA. It can thus be accessed by the kernel without additional checks. * For each userland thread we do create a user_thread structure in that area. The structure is accessible from userland via TLS, using the private get_user_thread() function. * Introduced private userland functions [un]defer_signals(). They can be used to cheaply disable/re-enable signal delivery. They use the user_thread::defer_signals/pending_signals fields which are checked/updated by the kernel. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25451 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4d3680aa |
|
10-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added timeout constant B_ABSOLUTE_REAL_TIME_TIMEOUT which specifies a timeout relative to the Epoch. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25434 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4c49f205 |
|
08-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed _kern_spawn_thread() and create_thread(): Instead of individual arguments they get a single thread_creation_attributes structure now. * Added stack_address and stack_size to thread_creation_attributes, which allow to specify the stack size or the stack to be used for the new user thread. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25389 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0c615a01 |
|
01-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Removed old mutex implementation and renamed cutex to mutex. * Trivial adjustments of code using mutexes. Mostly removing the mutex_init() return value check. * Added mutex_lock_threads_locked(), which is called with the threads spinlock being held. The spinlock is released while waiting, of course. This function is useful in cases where the existence of the mutex object is ensured by holding the threads spinlock. * Changed the two instances in the VFS code where an IO context of another team needs to be locked to use mutex_lock_threads_locked(). Before it required a semaphore-based mutex implementation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25283 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8562499f |
|
30-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced a new locking primitive I called "cutex" (sorry for the name, couldn't resist :-P). It's semantically equivalent to a mutex, but doesn't need a semaphore (it uses thread blocking and a simple queue instead). Initialization can't fail. In fact it is ready to use without initialization when living in the bss segment, also in the early boot process. It's as fast as a benaphore in cases of low lock contention, and faster otherwise. Only disadvantage is the higher immediate memory footprint of 16 bytes. * Changed how the "thread" and "threads" debugger commands list the objects they are waiting for. Cutexes are also included. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25276 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
210199c5 |
|
24-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Resolved {g,s}etrlimit() TODO's, i.e. moved the implementation into separate functions and made the set errno correctly. * Added RLIMIT_CORE case. We don't support core dumps, but setting them to disabled shouldn't fail anyway. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25141 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
60222c8b |
|
22-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Made thread_block_with_timeout_lock() more user-friendly. It allows passing 0 as timeout flags or B_INFINITE_TIMEOUT as timeout, in which case no timer will be used. * Implemented missing thread_block_with_timeout(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25104 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6cef245e |
|
22-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Detemplatized ConditionVariable{Entry}. Merged them with their respective Private* base class. * Changed sigwait() and sigsuspend() to use thread_block() instead of a condition variable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25100 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b95f6d47 |
|
22-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced a set of functions (thread_prepare_to_block(), thread_block(), thread_unblock(),...) that allow a thread to wait for something without needing a semaphore or condition variable. It can simply block and another thread can unblock it. Supports timeouts and interrupting. Both semaphores and condition variables use this common mechanism, now. * Semaphores: - Some simplifications due to the thread blocking mechanism. - Changed locking order to sem -> thread. It was the other way around before and when introducing the wait_for_objects() support I had also introduced a situation where the locking was reverse, which could potentially cause a dead lock on SMP systems. - Instead of queueing thread structures, a semaphore queues queued_thread entries now, which are created on the stack. The thread::sem structure could thus be removed. - Added sem_entry::net_count, which is sem_entry::count plus the acquisition count of all waiting threads. This number is needed in remove_thread_from_sem() and instead of computing it there we maintain it. - Fixed remove_thread_from_sem(). It would not unblock threads, if the sem count was <= 0. - Made sem::last_acquirer unconditional. It is actually needed for sem_info::latest_holder. Fixed fill_sem_info() accordingly. - Added some optional tracing output, though only via ktrace_printf(). * Condition variables: - Could be simplified significantly through the use of the thread blocking mechanism. Removed a good deal of unnecessary code. - Moved the ConditionVariableEntry "flags" parameter from Wait() to Add(), and adjusted all places where condition variables are used accordingly. * snooze() uses thread_block_with_timeout() instead of a semaphore. * Simplified thread interrupting in the signal and user debugger code. Instead of separate functions for threads waiting on a semaphore or condititon variable, we only have a single thread_interrupt(), now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25099 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
66aac81e |
|
20-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
We use only a single condition variable (instead of thread different ones) for wait_for_child(), which is notified when any job control condition (child dead, stopped, continued) occurs. These events are relatively rare anyway, and it simplifies the code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25079 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ef16b3bb |
|
10-Apr-2008 |
François Revol <revol@free.fr> |
Use the thread's stack size for RLIMIT_STACK, this should work even if we ever implement changing a thread's stack. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24898 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c4a7b4e0 |
|
10-Apr-2008 |
François Revol <revol@free.fr> |
Report the stack size from getrlimit(), we might want to get fancier later but that should be enough. Tcl will want that. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24893 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
758962ec |
|
26-Mar-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added arch_debug_contains_call() function that returns wether or not a call chain contains a specific symbol (or address). * Added a new KDL command "calling" that you can use to get a list of threads that have a specific function in their call chain. * Removed extraneous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24594 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4a7f236b |
|
09-Mar-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Process groups are now reference-counted. Processes in a group as well as the death entries of a deceased processes that were in this group and have not yet been reaped hold references to the group, so that it won't be deleted until the group is empty and all gone group members have been reaped. This fixes #1799 at last. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24335 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5b702e59 |
|
22-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
"thread" also prints the signal block mask, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24065 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0dd3108c |
|
21-Feb-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added SIGNAL_FLAG_DONT_RESTART_SYSCALL for send_signal_etc() which utilizes the THREAD_FLAG_DONT_RESTART_SYSCALL (but only in SIGCONT for now). * resume_thread() is now using that flag to be compatible with BeOS. * This fixes the Terminal hanging on close. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24045 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2efb87b9 |
|
20-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added TODO: Process groups should live on until the process is reaped. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24042 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4048494c |
|
17-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
axeld + bonefish: * Implemented automatic syscall restarts: - A syscall can indicate that it has been interrupted and can be restarted by setting a respective bit in thread::flags. It can store parameters it wants to be preserved for the restart in thread::syscall_restart::parameters. Another thread::flags bit indicates whether it has been restarted. - handle_signals() clears the restart flag, if the handled signal has a handler function installed and SA_RESTART is not set. Another thread flag (THREAD_FLAGS_DONT_RESTART_SYSCALL) can prevent syscalls from being restarted, even if they could be (not used yet, but we might want to use it in resume_thread(), so that we stay behaviorally compatible with BeOS). - The architecture specific syscall handler restarts the syscall, if the restart flag is set. Implemented for x86 only. - Added some support functions in the private <syscall_restart.h> to simplify the syscall restart code in the syscalls. - Adjusted all syscalls that can potentially be restarted accordingly. - _user_ioctl() sets new thread flag THREAD_FLAGS_IOCTL_SYSCALL while calling the underlying FS's/driver's hook, so that syscall restarts can also be supported there. * thread_at_kernel_exit() invokes handle_signals() in a loop now, as long as the latter indicates that the thread shall be suspended, so that after waking up signals received in the meantime will be handled before the thread returns to userland. Adjusted handle_signals() accordingly -- when encountering a suspending signal we don't check for further signals. * Fixed sigsuspend(): Suspending the thread and rescheduling doesn't result in the correct behavior. Instead we employ a temporary condition variable and interruptably wait on it. The POSIX test suite test passes, now. * Made the switch_sem[_etc]() behavior on interruption consistent. Depending on when the signal arrived (before the call or when already waiting) the first semaphore would or wouldn't be released. Now we consistently release it. * Refactored _user_{read,write}[v]() syscalls. Use a common function for either pair. The iovec version doesn't fail anymore, if anything could be read/written at all. It also checks whether a complete vector could be read/written, so that we won't skip data, if the underlying FS/driver couldn't read/write more ATM. * Some refactoring in the x86 syscall handler: The int 99 and sysenter handlers use a common subroutine to avoid code duplication. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23983 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9835c090 |
|
07-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added a boolean "force" parameter to thread_yield(). When true, the function has the old behavior. When false, it just calls the scheduler without any priority adjustment or other stuff. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23906 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2362422c |
|
03-Feb-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Do not just overwrite the thread state when suspending a thread since this easily causes problems on SMP systems (triggers the panic in the scheduler). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23839 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7694461e |
|
28-Jan-2008 |
Marcus Overhagen <marcusoverhagen@gmail.com> |
Use decimal for thread ids. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23779 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
62c35bb9 |
|
26-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Corrected "threads" usage text. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23756 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f2e758e5 |
|
26-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added usage message for the thread-related debugger commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23750 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6761f5a6 |
|
25-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Move the handling of still running threads into scheduler_enqueue_in_run_queue(). This should be in line with all uses of scheduler_enqueue_in_run_queue() and simplifies a few places where it is used. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23738 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
46cb5cfd |
|
18-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
When a main thread (i.e. a team) dies, we have to send the SIGCHLD to its parent while still holding the team spinlock. We were racing with wait_for_child(), since after the child invoked team_set_job_control_state(), the parent thread could continue as soon as the team spinlock was released. The SIGCHLD could thus arrive way later and interrupt another syscall. This could be reproduced with the compile_bench.sh script from time to time: When interrupted while waiting for the next subprocess, the gcc frontend would delete a still needed temporary file. The whole thing is actually only a problem, because we don't support automatic syscall restarts yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23625 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
34b3b26b |
|
10-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged branch haiku/branches/developer/bonefish/optimization revision 23139 into trunk, with roughly the following changes (for details svn log the branch): * The int 99 syscall handler is now fully in assembly. * Added a sysenter/sysexit handler and use it on Pentiums that support it (via commpage). * Got rid of i386_handle_trap(). A bit of functionality was moved into the assembly handler which now uses a jump table to call C functions handling the respective interrupt. * Some optimizations to get user debugger support code out of the interrupt handling path. * Introduced a thread::flags fields which allows to skip handling of rare events (signals, user debug enabling/disabling) on the common interrupt handling path. * Got rid of the explicit iframe stack. The iframes can still be retrieved by iterating through the stack frames. * Made the commpage an architecture independent feature. It's used for the real time data stuff (instead of creating a separate area). * The x86 CPU modules can now provide processor optimized versions for common functions (currently memcpy() only). They are used in the kernel and are provided to the userland via commpage entries. * Introduced build system feature allowing easy use of C structure member offsets in assembly code. Changes after merging: * Fixed merge conflict in src/system/kernel/arch/x86/arch_debug.cpp (caused by refactoring and introduction of "call" debugger command). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23370 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
92ab20b3 |
|
27-Nov-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added a list of death_entry's to the teams structure. It stores the exit status of (non-main) threads of a team. Fixes bug #1644. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23009 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d4fc2b7d |
|
18-Nov-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Fixed a bug reported by Ryan: the stack_end pointer of a thread was reported one too low in comparison with BeOS (ie. the end pointer was inclusive, now it's exclusive). * Moved static functions fill_thread_info(), and {send|receive}_data_etc() to the private function section. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22945 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
00ef60f6 |
|
12-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Removed the "next_*" in queue debugger commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22514 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
90bab16d |
|
11-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* IDs are now generally written as decimal numbers, rather than hexadecimal. * Fixed warnings with debug output turned on. * Shuffled functions around a bit. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22504 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
636bfc08 |
|
02-Oct-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Renamed fs/vfs_select.cpp to wait_for_objects.cpp and got rid of vfs_select.h, respectively moved most of it into the new kernel private header wait_for_objects.h. * Added new experimental API functions wait_for_objects[_etc](). They work pretty much like poll(), but also for semaphores, ports, and threads. * Removed the "ref" parameter from notify_select_events() and the select_sync_pool functions as well as from fd_ops::fd_[de]select(). It is no longer needed. The FS interface select() hook still has it, though -- the VFS will always pass 0. * de]select_fd() take a select_info* instead of a select_sync* + ref pair, now. Added respective functions for semaphores, ports, and threads. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22416 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3c367411 |
|
01-Oct-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed a race condition on thread exit: There was a gap between releasing the death stack and reacquiring the thread lock in which another thread could snatch our stack that we were still going to use for the scheduler. Now we've got a second spinlock that we can hold while releasing a semaphore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22403 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5c4ed86b |
|
27-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Moved some definitions from vm_types.h that functions in vm.h need as arguments into vm.h. * This should fix the broken build from earlier - thanks Stefano for the note! * That also allowed to clean some other includes a bit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22331 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e6dc7903 |
|
26-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm.h no longer includes vm_types.h - only those that actually need access to the private VM types are including vm_types.h now. * Removed vm_page, vm_area, vm_cache, and vm_address_space typedefs; it's cleaner this way, and the actual types are only used in C++ files now, anyway. * And that caused changes in many files... * Made commpage.h self-containing. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22329 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
24bcf559 |
|
27-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced new job_control_entry structure which, among other things, is used instead of death_entry for team::dead_children. * Added team::{stopped,continued}_children, which, analoguously to dead_children, are used to track the state of stopped/continued children. * A team does have a job_control_entry, which is allocated at team creation time. It will be inserted into the parent's {stopped,continued}_children lists as the team's main thread is stopped/continued and removed when waitpid() retrieves the child state. When the team dies the entry is detached from the team and goes into the parent's dead_children list. * Removed the wait_for_any field from team_dead_children. It was solely used to avoid deletion of the contained entries in certain situations. wait_for_child() (the waitpid() backend) always deletes an entry now, regardless of whether other threads are waiting; that's in accordance with the waidpid() specification. wait_for_thread() removes the entry only, if the caller is the parent of the respective team. * Introduced team_set_job_control_state() which performes the job control entry transitions between the respective lists and wakes up threads waiting in wait_for_child(). It is invoked on team death and when the team's main thread receives job control signals. * Reorganized wait_for_child(). It handles WCONTINUED and WUNTRACED now, too. Removed a block that interpreted the supplied ID as thread ID. * Added missing parts in waitpid(). Job control starts to work, though it seems to have some glitches. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22088 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ff895459 |
|
27-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Replaced the team::dead_children::sem semaphore by a condition variable. Due to C code including the header I had to turn it from and aggregated member to a pointer. I'm very close to starting to convert all remaining .c to .cpp files. :-/ * Got rid of the "waiters" field. It was only written, never read. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22084 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ff308b0b |
|
26-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Condition variables changes: * Removed left-over commented C implementation. * It is now possible for a thread to wait for more than one condition variable at a time. * Made waiting for condition variables optionally interruptable. * Renamed Notify() method to NotifyAll() and added a NotifyOne(), so that it is now possible to wake up only one of the waiting threads. Pretty much untested at the moment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22081 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
61b50eed |
|
26-Aug-2007 |
Jérôme Duval <korli@users.berlios.de> |
fix gcc4 build git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22080 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ebe6d106 |
|
26-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Turned the files I intend to devastate to C++. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22074 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
744dfa3c4c7fe5ed85e665259bb7cc4486a476e7 |
|
18-Apr-2014 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: make sure thread priority is within valid range The scheduler expects that all threads expect the initial idle threads have priority in range [THREAD_MIN_SET_PRIORITY, THREAD_MAX_SET_PRIORITY]. If the requested pririty is out of range the value is clamped. Failing with B_BAD_VALUE is probably an overkill since there isn't any real change in the guarantees provided by the scheduler about the behavior of such thread. Also, BeBook suggests that spawn_thread() can specify priority 0.
|
#
e6ea745e8114d5fa05ab0ccab92c070e2dcdcfb7 |
|
06-Dec-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Use SMP_MAX_CPUS instead of B_MAX_CPU_COUNT
|
#
2b7ea4cddf362859cd3089e3cb95481cda4adc5f |
|
29-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove Thread::next_state
|
#
673f08a995666c3e818bf0f936152f34f8b1e81e |
|
28-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Make thread_block_locked() private
|
#
286b341a400e8d12060a8be52214618b8f02df87 |
|
28-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Merge two occurences of thread resume code
|
#
03f7d3d1db10c0a467bea944fb3230ee70c6e015 |
|
24-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Restore logical processor disabling
|
#
288a2664a2de429f159d746beaab87373184cd3d |
|
12-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
scheduler: Remove sSchedulerInternalLock * pin idle threads to their specific CPUs * allow scheduler to implement SMP_MSG_RESCHEDULE handler * scheduler_set_thread_priority() reworked * at reschedule: enqueue old thread after dequeueing the new one
|
#
a1feba678d5e14e240183ba775b799384f0708e1 |
|
11-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel/undertaker: Make sure the thread isn't running anymore
|
#
03fb2d886830e4dd4b344c56725db59f96733216 |
|
07-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove gSchedulerLock * Thread::scheduler_lock protects thread state, priority, etc. * sThreadCreationLock protects thread creation and removal and list of threads in team. * Team::signal_lock and Team::time_lock protect list of threads in team as well. * Scheduler uses its own internal locking.
|
#
72addc62e042d2a39fba1f04e2cc8dadc155adfe |
|
07-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Introduce Thread::time_lock and Team::time_lock
|
#
3519eb334ac161e88fa56bcef287a2275a1c963e |
|
06-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Change Thread::team_lock to rw_spinlock
|
#
83983eaf38ac442edaa4418de4b6a389e911c72d |
|
06-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove Thread::alarm
|
#
aa4aca0264aa285e07c0b8e43112ac06803fcd2e |
|
06-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Protect signal data with Team::signal_lock
|
#
11cacd0c1345cd3296f12e07d18996a2c7572a64 |
|
04-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove thread_block_with_timeout_locked()
|
#
c2763aaffbd34bd92065b97c0f2770e418824772 |
|
30-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Add spinlock for undertaker data
|
#
d8fcc8a82519cef977c689cee497316be6f1531f |
|
30-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove B_TIMER_ACQUIRE_SCHEDULER_LOCK flag The flag main purpose is to avoid race conditions between event handler and cancel_timer(). However, cancel_timer() is safe even without using gSchedulerLock. If the event is scheduled to happen on other CPU than the CPU that invokes cancel_timer() then cancel_timer() either disables the event before its handler starts executing or waits until the event handler is done. If the event is scheduled on the same CPU that calls cancel_timer() then, since cancel_timer() disables interrupts, the event is either executed before cancel_timer() or when the timer interrupt handler starts running the event is already disabled.
|
#
c8dd9f7780c426e592a3ccb231e6bfab51f15eb9 |
|
29-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Add thread_unblock() and use it where possible
|
#
978fc080654a2367cfb75a8afa196361ab56645e |
|
23-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
scheduler: Remove support for running different schedulers Simple scheduler behaves exactly the same as affine scheduler with a single core. Obviously, affine scheduler is more complicated thus introduces greater overhead but quite a lot of multicore logic has been disabled on single core systems in the previous commit.
|
#
7e1ecb9315396949d3197916c1a3bf67a0fee22c |
|
23-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Protect scheduler_set_thread_priority() with lock
|
#
ea79da95009a2f916bebbd5d3b57281035548e25 |
|
20-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove support for thread_queue
|
#
84812e60330406dba1151fe43d1d61ddeb498466 |
|
20-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
scheduler_affine: Correctly assign CPUs to idle threads
|
#
f20ad54be26d164713bd06dab0435cee985561ef |
|
14-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Add support for SMP systems to simple scheduler In SMP systems simple scheduler will be used only when all logical processors share all levels of cache and the number of CPUs is low. In such systems we do not have to care about cache affinity and the contention on the lock protecting shared run queue is low. Single run queue makes load balancing very simple.
|
#
29e65827fd93f67acbebcdbbe1f233b004a48e18 |
|
09-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove possibility to yield to all threads Kernel support for yielding to all (including lower priority) threads has been removed. POSIX sched_yield() remains unchanged. If a thread really needs to yield to everyone it can reduce its priority to the lowest possible and then yield (it will then need to manually return to its prvious priority upon continuing).
|
#
fee8009184189f5aa56d759f3f9974313013fbbc |
|
09-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Add another penalty for CPU bound threads Each thread has its minimal priority that depends on the static priority. However, it is still able to starve threads with even lower priority (e.g. CPU bound threads with lower static priority). To prevent this another penalty is introduced. When the minimal priority is reached penalty (count mod minimal_priority) is added, where count is the number of time slices since the thread reached its minimal priority. This prevents starvation of lower priorirt threads (since all CPU bound threads may have their priority temporaily reduced to 1) but preserves relation between static priorities - when there are two CPU bound threads the one with higher static priority would get more CPU time.
|
#
130000e068ec68a10fc632ee4ffc8a5fb563159b |
|
08-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Dump scheduler specific thread data
|
#
0896565a6e405d3543b15772571138d622c7fba9 |
|
08-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Support sched_yield() properly sched_yield() should not yield to the threads with lower priority.
|
#
9363e99b19d122db7d6684b06d7240fb73255cd2 |
|
08-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove Thread::next_priority
|
#
03e3a8295375a672734943bcaa489ad09b22ac35 |
|
07-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Allow threads to yield CPU properly
|
#
2eb2b522bf0b3533a7a35bc5fa8d1caa0d2573d2 |
|
01-Jul-2013 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Enforce team and thread limits Also fixes incorrect team accounting in case of error when creating a team. The previously incremented sUsedTeams wasn't decremented again.
|
#
c24adb29503ec78c6d076801e1d82d16140e3413 |
|
19-Apr-2013 |
Rene Gollent <anevilyak@gmail.com> |
Rework DefaultNotificationService registration. - Instead of implicitly registering and unregistering a service instance on construction/destruction, DefaultNotificationService now exports explicit Register()/Unregister() calls, which subclasses are expected to call when they're ready. - Adjust all implementing subclasses. Resolves an issue with deadlocks when booting a DEBUG=1 build.
|
#
17c189899a44d373f21f26a0886256ee6e3ff1a3 |
|
26-Feb-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
thread: randomize user stack position Use B_RANDOMIZE_BASE_ADDRESS for creating both main and other threads user stack.
|
#
d1f280c80529d5f0bc55030c2934f9255bc7f6a2 |
|
01-Apr-2012 |
Hamish Morrison <hamishm53@gmail.com> |
Add support for pthread_attr_get/setguardsize() * Added the aforementioned functions. * create_area_etc() now takes a guard size parameter. * The thread_info::stack_base/end range now refers to the usable range only.
|
#
6912e7dc034b05bba63db4480f0d94539628d1f8 |
|
23-Aug-2012 |
Edward Robbins <edd.robbins@gmail.com> |
getrlimit with RLIMIT_STACK now returns USER_MAIN_THREAD_STACK_SIZE Signed-off-by: Rene Gollent <anevilyak@gmail.com>
|
#
07c6bd65b8aa82eae10c036e674799c1c5d16be9 |
|
23-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Format string fixes for TRACE_{THREAD,TEAM}.
|
#
c3f0fd28cda13d70a8c092003609442e4e29cf78 |
|
12-Jul-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Fixed formatting of output in some debugger commands. Currently all debugger commands assume 32-bit pointers when formatting their output. This means that on x86_64 the output is incorrectly formatted. Fixed this by adding a B_PRINTF_POINTER_WIDTH definition (16 on 64-bit, 8 on 32-bit), and using this to correctly format the output. Not all commands have been fixed yet, but all VM, slab, VFS, team, thread and image commands should be correct.
|
#
92284dcc2cc283de8cf553889891ae46aa2ba991 |
|
08-Jul-2012 |
Pawel Dziepak <pdziepak@quarnos.org> |
nfs4: Use semaphore to cancel threads instead of interrupt_thread()
|
#
e552920f09647d2e8a0743dceac5a37f1d57c5be |
|
30-May-2012 |
Pawel Dziepak <pdziepak@quarnos.org> |
nfs4: Fix rpc listener thread cancelation recv on UDP sockets is not interrupted when the socket is closed. Additionaly, signals do not interrupt kernel threads, that is why new function interrupt_thread was implemented in order to cancel listener thread.
|
#
294711f98c107cf2d9d05b7fc34cd863e87bd358 |
|
27-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
Changed {,u}int64 to be long rather than long long on x86_64.
|
#
4be4fc6b1faddbd037146214a0011d320842b4f3 |
|
15-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
More 64-bit compilation/safety fixes.
|
#
4bbb27e3ccf0b1e38ee4a63ca9ec765e167a72bd |
|
12-Feb-2012 |
Jerome Duval <jerome.duval@gmail.com> |
More 'GCC4.6 variable set but not used' fixes.
|
#
88520e79d880a7631e3a7dd02c27df84c4602cd3 |
|
12-Feb-2012 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
create_thread_user_stack(): Fix incorrect handling of TLS size In case a custom stack was given, the TLS size was subtracted from the stack base, not the stack size.
|
#
62bb375688f215aea630095416df8dd8a169d295 |
|
05-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Restructure wait_for_thread_etc() to make it easier to follow. * Avoid needless adding of the death entry if the sem is gone already. * Delete objects as soon as they aren't needed anymore and return early where possible. * Contain the thread == NULL case in its block and return from there as well instead of non-obviously figuring out what happened later. * Pull out the return code asignment. * Minor cleanup.
|
#
da329fc01237545c8f5678497a2ffb8409dd3ba4 |
|
05-Dec-2011 |
Michael Lotz <mmlr@mlotz.ch> |
Add missing asignment of return code in wait_for_thread_etc(). While it was detected that the thread is in the destruction phase and that it was necessary to wait and then have a valid status code in the death entry, that status code wasn't actually returned. This lead to uninitialized values for the return code even though wait_for_thread[_etc]() would return B_OK.
|
#
552d99013ab95709e7a8ecc7d34ef93c6e431f2f |
|
26-Nov-2011 |
Philippe Saint-Pierre <stpere@gmail.com> |
Replace usage of sprintf with snprintf Fixing CID 10964
|
#
fae2ce1945fb1f791d4ccbab8422bcc7d7de8a3f |
|
07-Nov-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Enlarge threads and ports KMessage notification stack buffers They were too small for all the fields added. This is why the system profiler skipped "thread added" notifications. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43216 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
17f2def171362c0c6de65ea0de4cf1ec4219b554 |
|
28-Sep-2011 |
Rene Gollent <anevilyak@gmail.com> |
Only call UserDefinedTimersRemoved if there actually are any. Should fix #7998. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42776 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9437559db1ae72a12b0edec44d4c538a08ceac0f |
|
14-Jun-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added function team_init_exit_info_on_error() which initializes the team's exit info with some generic status. * team_create_thread_start(), common_thread_entry(): Initializes the team's exit info (if that's the main thread) before calling thread_exit(). Fixes #7686. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42183 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
24df65921befcd0ad0c5c7866118f922da61cb96 |
|
11-Jun-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged signals-merge branch into trunk with the following changes: * Reorganized the kernel locking related to threads and teams. * We now discriminate correctly between process and thread signals. Signal handlers have been moved to teams. Fixes #5679. * Implemented real-time signal support, including signal queuing, SA_SIGINFO support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition of the real-time signal range. Closes #1935 and #2695. * Gave SIGBUS a separate signal number. Fixes #6704. * Implemented <time.h> clock and timer support, and fixed/completed alarm() and [set]itimer(). Closes #5682. * Implemented support for thread cancellation. Closes #5686. * Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554. * Lots over smaller more or less related changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
57ceeee424f42dbacc2aed48353428833d959165 |
|
26-Feb-2011 |
Jérôme Duval <korli@users.berlios.de> |
copy sig_action structure from the current thread if we're the same team. Helps with #7235 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40701 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4535495d80c86e19e2610e7444a4fcefe3e0f8e6 |
|
10-Jan-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged the signals branch into trunk, with these changes: * The team and thread kernel structures have been renamed to Team and Thread respectively and moved into the new BKernel namespace. * Several (kernel add-on) sources have been converted from C to C++ since private kernel headers are included that are no longer C compatible. Changes after merging: * Fixed gcc 2 build (warnings mainly in the scary firewire bus manager). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b734adba63be8189571361bd16a30ec3f586bc8d |
|
02-Jan-2011 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
find_thread(): thread::name is an array, so the NULL check is useless (CID 4073). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40083 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4ebc8f615d5a495671343519051b9094b2867808 |
|
15-Dec-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added a "name changed" notification to the thread notification service. * Added a "team" field to the notification events. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39861 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
27a115f6685cc7821dd2ab6d528d6f3abe70158d |
|
14-Dec-2010 |
Rene Gollent <anevilyak@gmail.com> |
Revert r39846 and r39847. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39849 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7040b50df5e1483f3e982d5b7ef7c7f79a898b93 |
|
13-Dec-2010 |
Rene Gollent <anevilyak@gmail.com> |
Add support for thread rename and priority change notifications to the debugger API/message set. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39846 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
44db70a313dd536b87593acde170341a5dbae5b3 |
|
15-Jul-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Resolved TODO: Use an object cache for the thread structure alloction. * Align the allocated objects to 16 byte. This is required by the x86 arch_thread structure. Haiku only didn't crash and burn since the until recently used heap allocator apparently aligned the structures to 16 byte anyway and the now used slab allocator has a bug preventing slab coloring for that object size. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37532 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3121f3948144b77af20a56ac2679e93e54b05b42 |
|
13-Jul-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
thread_exit(): Postpone deleting the thread's user stack until after sending the thread's death notifications. The fixes issues where other threads depend on objects on its stack (particularly relevant for the main thread). Fixes #6315. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37509 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a8ad734f1c698917badb15e1641e0f38b3e9a013 |
|
14-Jun-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced structures {virtual,physical}_address_restrictions, which specify restrictions for virtual/physical addresses. * vm_page_allocate_page_run(): - Fixed conversion of base/limit to array indexes. sPhysicalPageOffset was not taken into account. - Takes a physical_address_restrictions instead of base/limit and also supports alignment and boundary restrictions, now. * map_backing_store(), VM[User,Kernel]AddressSpace::InsertArea()/ ReserveAddressRange() take a virtual_address_restrictions parameter, now. They also support an alignment independent from the range size. * create_area_etc(), vm_create_anonymous_area(): Take {virtual,physical}_address_restrictions parameters, now. * Removed no longer needed B_PHYSICAL_BASE_ADDRESS. * DMAResources: - Fixed potential overflows of uint32 when initializing from device node attributes. - Fixed bounce buffer creation TODOs: By using create_area_etc() with the new restrictions parameters we can directly support physical high address, boundary, and alignment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37131 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d3166e469cd337a6910f1cb1515b74f73d36466f |
|
29-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Replaced no longer necessary send_signal_etc() work-arounds for resume_thread(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36531 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5a0b30dbda413b39b926ca3d79bc2acfbeef1be4 |
|
06-Apr-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Don't cancel the alarm on exec*(). POSIX alarm() requires that. The BeBook doesn't mention the expected set_alarm() behavior. Tests under BeOS R5 Bone crash the system in either case, though, so I guess we're free to go with the expected POSIX behavior. This make detection of hanging tests in the Open POSIX Test Suite work. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36046 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7778bccf93001545b6e9e7a839d41146fa000700 |
|
13-Mar-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
sigsuspend() would previously wake up correctly when a matching signal was received, but if the signal was in the thread's signal block mask, it would not be handled. Added thread::sig_temp_enabled, an additional mask of not blocked signals, which is set by sigsuspend() and evaluated and reset by handle_signals(). Fixes #5567. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35836 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
cee04e8074ec61fd8c6dac3539c5b821c3618888 |
|
08-Feb-2010 |
Artur Wyszynski <aljen-mlists@o2.pl> |
Fixed various errors/warnings reported by cppcheck: * memory leaks * resource leaks * added const's to getters * removed a few reundant conditions git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35433 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5662ae45852e028a196015a0309d04a46ad657f3 |
|
20-Jan-2010 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Changed the team shutdown process a bit: * The threads beside the main thread are killed earlier now (in the new team_shutdown_team()), before removing the team from the team hash and from its process group. This fixes #5296. * Use a condition variable instead of a semaphore to wait for the non-main threads to die. We notify the condition right after a thread has left the team. The semaphore was released by the undertaker. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35196 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0338371f26864c2a248b1ea53b9fe78c884af7f2 |
|
13-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* All scheduler implementations: - enqueue_in_run_queue() no longer returns whether rescheduling is supposed to happen. Instead is sets cpu_ent::invoke_scheduler on the current CPU. - reschedule() does now handle cpu_ent::invoke_scheduler_if_idle(). No need to let all callers do that. * thread_unblock[_locked]() no longer return whether rescheduling is supposed to happen. * Got rid of the B_INVOKE_SCHEDULER handling. The interrupt hooks really can't know, when it makes sense to reschedule or not. * Introduced scheduler_reschedule_if_necessary[_locked]() functions for checking+invoking the scheduler. * Some semaphore functions (e.g. delete_sem()) invoke the scheduler now, if they wake up anything with greater priority. I've also tried to add scheduler invocations in the condition variable and mutex/rw_lock code, but that actually has a negative impact on performance, probably because it causes too much ping-ponging between threads when multiple locking primitives are involved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34657 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a195cce7b5776cc64518b70687d336e54b895ab7 |
|
12-Dec-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Added a bit more missing info about user_threads. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34647 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b4be7c902190522214ae7532900725b8f446ef8e |
|
11-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added cpu_ent::running_thread which is maintained by the schedulers. * simple_smp scheduler: Rewrote the interesting part of enqueue_in_run_queue(). It always selects a target CPU for the inserted thread, now. If no CPU is idle, the CPU running the thread with the lowest priority is chosen. If the thread running on the target CPU has a lower priority than the inserted one, it will be asked to reschedule. If that's the current CPU, we'll return the correct value (wasn't done before at all). These changes help reducing latencies. On my machine in an idle system playing music DebugAnalyzer shows maximum latencies of about 1 us. I still find that a bit much, but it's several orders of magnitude better than before. The -j8 Haiku image build time dropped about 10%. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34635 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3533b6597db4ad65493632da8a92c1f6ea3de149 |
|
10-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Reintroduced the SMP_MSG_RESCHEDULE_IF_IDLE ICI message. This time implemented by means of an additional member in cpu_ent. * Removed thread::keep_scheduled and the related functions. The feature wasn't used yet and wouldn't have worked as implemented anyway. * Resurrected an older, SMP aware version of our simple scheduler and made it the default instead of the affine scheduler. The latter is in no state to be used yet. It causes enormous latencies (I've seen up to 0.1s) even when six or seven CPUs were idle at the same time, totally killing parallelism. That's also the reason why a -j8 build was slower than a -j2. This is no longer the case. On my machine the -j2 build takes about 10% less time now and the -j8 build saves another 20%. The latter is not particularly impressive (compared with Linux), but that seems to be due to lock contention. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34615 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e50cf8765be50a7454c9488db38b638cf90805af |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved the VM headers into subdirectory vm/. * Renamed vm_cache.h/vm_address_space.h to VMCache.h/VMAddressSpace. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34449 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
90d870c1556bdc415c7f41de5474ebebb0ceebdd |
|
02-Dec-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved VMAddressSpace definition to vm_address_space.h. * "Classified" VMAddressSpace, i.e. turned the vm_address_space_*() functions into methods, made all attributes (but "areas") private, and added accessors. * Also turned the vm.cpp functions vm_area_lookup() and remove_area_from_address_space() into VMAddressSpace methods. The rest of the area management functionality will follow soon. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34447 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8665c30ace2b0b23b862a635ba0ff696d371f2d9 |
|
07-Nov-2009 |
Michael Lotz <mmlr@mlotz.ch> |
That was not such a good destruction order in the error case. As the scheduler accesses the scheduler data inside the thread structure, freeing it first lead to a crash when a thread couldn't be created. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33940 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6390c0ca808dd8d6a609ed59964d74d40d0dda87 |
|
22-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* _get_next_thread_info() should be a bit more picky about its team needs. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33741 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3530c3eb6beaae68aedf691499de68268a2217a4 |
|
22-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Reimplemented the insane _get_next_thread_info() which previously just iterated over all known thread *IDs* with interrupts disabled. Now it iterates over the team's thread list (going from back to front, since new threads are added at the front of the singly linked queue). * Alexandre restarted Tracker quite a lot, and let the shell script run to reproduce a certain bug - and then wondered why ProcessController would take several seconds to open its windows until it passed through more than 8 million IDs... :-) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33737 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
68d9d8809bd7ed208ac27f2a747fc0b3b9b78539 |
|
22-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Just use the heap instead of cbuf for send_data(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33722 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ea95b4d03ef5b2d8dab7b1b87b33f9049cea9e56 |
|
14-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Cleanup, no functional change. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33580 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
009ccc29623e2b54f3e881739754c5cea121e7d6 |
|
20-Aug-2009 |
Rene Gollent <anevilyak@gmail.com> |
anevilyak+mmlr: * scheduler_enqueue_in_runqueue() now allows the scheduler to return a hint as to whether a reschedule is desirable or not. This is used in a few other places in order to relegate scheduling decisions entirely to the scheduler rather than the priority hacks previously used. There are probably other places in the kernel that could now make use of that information to more intelligently call reschedule() though. * Switch over the default scheduler to scheduler_affine(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32554 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d3b44ccb1470db823a443d0f9b32e09bfa0d0a9c |
|
29-Jul-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added explicit physical address parameter to vm_create_anonymous_area() and create_area_etc(). 0 for the default behavior. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31941 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ba391bcc56771ed5e881a4478d3c6a7273a29f1c |
|
22-Jun-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added team_debug_info::debugger_changed_condition to serialize changes to the installed team debugger and adjusted the code accordingly. It's not needed yet, but I intend to add support for software breakpoints and those require a bit of uninitialization that needs to be synchronized with debugger changes and can't be done with interrupts disabled. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31194 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6ad4a777b6ee1202c6aa95ff40e24e8932699843 |
|
14-Jun-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Also set user_thread to NULL. It shouldn't make a difference, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31040 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
591bc3f2d99168a9b2a9bdcbda20c47e97a4ff80 |
|
28-May-2009 |
Jérôme Duval <korli@users.berlios.de> |
* various fixes identified by gcc4, provided by Joe Prostko git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30902 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
efd536ff89954302f42c59e2c71fba45e5cb4c25 |
|
11-Apr-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Cleared up a misconception in the notification mechanism. We already had methods that used an "event mask" field. There was no need to introduce a "flags" field for the same purpose. * Renamed protected DefaultNotificationService methods (removed "_" prefix). * Adjusted the code providing a notification service accordingly. * Changed the event message several notification services generated by renaming the "opcode" field to "event". * Implemented the TEAM_ADDED event and also added a TEAM_EXEC event. * Added notifications for threads and images. * Added visitor-like iteration functions for teams, threads, and images. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30126 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ec29f0842c9a787eeca9f2ce3783cd61bc7ad39e |
|
04-Apr-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
bonefish + mmlr: Don't really resume the undertaker thread after creating it, since at that point the scheduler has not been started yet. Didn't do any harm, since it was only the second thread anyway and the idle thread was rescheduled almost immediately. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29908 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0296b82ae6a0f131f1fea3edfe21032bd2cf3f5c |
|
25-Mar-2009 |
Rene Gollent <anevilyak@gmail.com> |
Add several extra scheduler hook functions to allow the scheduler(s) to maintain private housekeeping data on the thread structs. These hooks are called on thread creation/destruction and when prepping a thread for use. Review welcome. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29721 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4c35c6b5e1a38b820b2f57a37ebc4e4e8c7906eb |
|
17-Mar-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* _user_unblock_thread[s]() also set the user thread's wait_status, now. This makes them more convenient to use, since the caller doesn't need to know the target threads' user thread structure. * Adjusted the pthread rwlock implementation accordingly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29578 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c33667d400856680a8e0122300861eda77d1847a |
|
01-Feb-2009 |
Michael Lotz <mmlr@mlotz.ch> |
Fixing warnings under GCC4 in preparation to enable -Werror there as well: * Replaced the use of offsetof() for structs that aren't PODs. Add a offset_of_member() macro to util/khash.h because that's what it's used for in our cases. * Change the signature of add_debugger_command()/remove_debugger_command() on GCC > 2 to avoid the depricated conversion from string constants to char *. * Adding some "suggested" parenthesis. I know that not everyone likes that, but it pointed out at least one bug that is fixed here as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29113 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2c1e463c7e1b9165731cfb86918d2c67b8496b6c |
|
05-Nov-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Removed B_{MIN|MAX}_PRIORITY from OS.h - they were never really intended as public defines. They are now called THREAD_{MIN|MAX}_SET_PRIORITY to better reflect what they are for. Minimum priority is now 1, ie. you no longer can set another thread to the idle priority. This fixes part of ticket #2959. * set_thread_priority() will no longer allow to change the priority of the idle thread to something else. This fixes the rest of ticket #2959. * Automatic whitespace cleanup in OS.h. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28521 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
53892c92a02939d7e657f4fbb9563bc692716318 |
|
20-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Replaced scheduler_remove_from_run_queue() by scheduler_set_thread_priority(). Setting the thread priority was the only situation in which it was used. * Renamed scheduler.cpp to scheduler_simple.cpp. * The scheduler functions are no longer called directly. Instead there's an operation vector now, which is initialized at kernel init time. This allows for picking the most suitable scheduler for the machine (e.g. a non-SMP scheduler on a non-SMP machine). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28262 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
808de9c7004d1e85fc37fbd39382b1ca58c0f470 |
|
17-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* The undertaker was not locking when enqueuing the thread structure in the free queue. * "thread" also prints the thread's I/O priority. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28218 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1e2bc11e996491ca1d3a44f5826ab29b312120c6 |
|
16-Oct-2008 |
François Revol <revol@free.fr> |
bonefish+mmu_man: fix cbuf_user_memcpy_from_chain() returning an error when the source buffer was NULL despite being asked for 0 bytes, while the counterpart was actually not creating a buffer for 0 bytes to send... Also don't bother calling it from receive_data() in that case anyway. This fixes a deadlock in SoundPlay that made it freeze when trying to play the 2nd sound. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28179 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6503e5d9c6ab89ebb681b4819b07d3ff4890e5fb |
|
11-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added functions to pin a thread to the current CPU (i.e. it will only be scheduled on that CPU) and to avoid unscheduling it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27974 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
74785e79db32355e0a8ee6b488672ac09ad57b1b |
|
07-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added "from" address space parameter to vm_swap_address_space()/ arch_vm_aspace_swap(). * The x86 implementation does now maintain a bit mask per vm_translation_map_arch_info indicating on which CPUs the address space is active. This allows flush_tmap() to avoid ICI for user address spaces when the team isn't currently running on any other CPU. In this context ICI is relatively expensive, particularly since we map most pages via vm_map_page() and therefore invoke flush_tmap() pretty much for every single page. This optimization speeds up a "hello world" compilation about 20% on my machine (KDEBUG turned off, freshly booted), but interestingly it has virtually no effect on the "-j2" haiku build time. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27912 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
032ff97fbd8361146a37a3af6b6760db1d3c4afb |
|
06-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
When a thread times out on a locking primitive, reschedule only, if the timed out thread has a higher priority than the currently running one. Maybe we should even restrict this behavior to realtime threads. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27897 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
23884ae0250a1731e1f880ec0d971c4f32c88eea |
|
19-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Introduced a callback field in the thread structure. It can be set in an interrupt handler and will be executed right before returning from the interrupt. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27648 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
cbcebd3330d8701dd854e5958a28bf7e1af50df4 |
|
15-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Extended the debugger API by sampling-based profiling support. This is still pretty much work in progress. * Introduced init_thread_debug_info() which is used instead of clear_thread_debug_info() when the thread is created. The latter requires former initialization. * user_debug_thread_deleted() is now already invoked in thread_exit(), not in the undertaker. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27531 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c2a59f2305c6f4f1870078076ce28e71835924e7 |
|
12-Sep-2008 |
Ryan Leavengood <leavengood@gmail.com> |
Remove the null check as per Axel's advice: valid arguments within the range are never null. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27450 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d1363991a8f1f7ad5079fab05d16c18c8827c166 |
|
11-Sep-2008 |
Ryan Leavengood <leavengood@gmail.com> |
Fixed CID 1299: the char* name was used in a call to strtoul on line 1220 before being NULL checked on line 1234. I moved the null check to be after name is initialized and removed it from line 1234. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27428 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
89cfd54279e8ce6d5432e60e8ba3d881d40fd3d5 |
|
04-Sep-2008 |
Karsten Heimrich <host.haiku@gmx.de> |
* revert r27322 and apply the patch provided by Salvatore Thanks you! :) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27323 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3b3e3805f8e693bbb48ab203379efd47fb7e73dc |
|
30-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added thread::io_priority field and functions to get/set it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27247 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
07569b03c9d1cd80a23479243e9aef030f66272c |
|
22-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added kernel private thread_state_to_text() which just calls state_to_text(). * state_to_text() can now deal with a NULL thread argument. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27163 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
16cfc87748f85b7d96cae5c9ae811256699d4b65 |
|
22-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added option "-s" to the "thread" command, which prints the info in short form (like "threads"). * "thread" allows to specify more than one thread now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27152 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1e90630527225143d9321738152bba9194f5ef3f |
|
21-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added a "flags" parameter to vm_create_anonymous_area() and create_area_etc(). * When the new flag CREATE_AREA_DONT_WAIT is specified, the functions don't wait for memory or pages to become available. They fail immediately instead. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27117 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3b99126c1e271c45ea7d5a19600438724e53404d |
|
12-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed table columns alignment in the "threads" command. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26948 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
57f2b5a0137be29081ab719ae33ebabddc95b78b |
|
05-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed the meaning of the {KERNEL,USER}_STACK_SIZE macros to not include the guard pages. Adjusted the kernel and boot loader code accordingly -- the guard pages size is added/not removed respectively. The stack size passed to _kern_spawn_thread() is now the actually usable size, and it is no longer possible to specify a size smaller than or equal to the guard pages size. * vm_create_anonymous_area(): Precommit two pages maximum -- a stack with only one page usable size obviously doesn't need two pages. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26819 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
a9d458d8dbcc40eb4f9d133baa77fef658a3635b |
|
02-Aug-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Also init kernel_stack_top for the idle threads. It was NULL before, which caused stack traces in those threads to crash. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26746 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
15374c5dbdb2c6b700bb2191887cadad7ef9eb73 |
|
02-Aug-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed thread_spinlock and team_spinlock to gThreadSpinlock and gTeamSpinlock. * Renamed the static global variables in smp.c to match our style guide. * Minor other cleanup. * Removed superfluous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26730 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
12c9f1761f8f6ea4c74c4cf4634b660df1a326d4 |
|
31-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added thread block type constant for rw_locks, so that they are listed correctly by the "thread" and "threads" debugger commands. * Added "rwlock" debugger command. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26703 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
736352dcf58f1855db8dc09c456d420ca91596ef |
|
16-Jul-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added [un]lock_memory_etc() versions that accept a team_id as first argument. This allows drivers to lock the memory outside of the original team context. * create_area_etc() got a struct team as first argument, but that should have been a team_id. * Removed delete_area_etc() - there is already vm_delete_area() doing the same thing. * Renamed vm_get_address_space_by_id() to vm_get_address_space(), as there is no other method of getting an address space. * Removed erroneous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26455 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
dc271293321d3eabe5dcf7cd33a01aa3b790d477 |
|
03-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
stippi + bonefish: * Missing backslash in UPDATE_THREAD_KERNEL_TIME() macro. Caused the thread's kernel time never to be updated when the thread left the kernel. The time would be added to the user time instead. * Changed semantics of thread_at_kernel_exit(). It leaves interrupts disabled when returning, now. All code using it would disable interrupts afterwards anyway, and inbetween the thread could be interrupted causing two more time updates (or actually not causing them erroneously). * The code in x86's interrupt handler entry (int_bottom) also checks thread::in_kernel now, to determine whether the thread was already considered to be in userland. This is necessary since the sysexit instruction doesn't reenable interrupts, so that we have to do that with the preceeding instruction. Hence an interrupt can occur inbetween, which would incorrectly add the interrupt's kernel time to the thread's user time. * For userland threads team_create_thread_start() didn't invoke thread_at_kernel_exit() or any equivalent. We do that in arch_thread_enter_userspace() now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26240 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0cb2617fa541dbcf53188b492a34f96ad0cf4ef8 |
|
01-Jun-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Before starting to wait the undertaker does now check whether there's already a dead thread available. Fixes a race condition. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25754 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1c8de8581b66c14ea94bccd7ddcea99291955796 |
|
01-Jun-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Added optional spinlock contention measurement feature. Enabled when B_DEBUG_SPINLOCK_CONTENTION is defined to 1. It typedefs spinlock to a structure (thus breaking BeOS binary compatibility), containing a counter which is incremented whenever a thread has to wait for the spinlock. * Added macros for spinlock initialization and access and changed code using spinlocks accordingly. This breaks compilation for BeOS -- the macros should be defined in the respective compatibility wrappers. * Added generic syscall to get the spinlock counters for the thread and the team spinlocks. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25752 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
91015353227faf43c2493570b5d96a919ff63dd9 |
|
29-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added new kernel thread "undertaker" which gets rid of dead thread remains. This replaces the previous mechanism of switching the thread to a dedicated death stack. We might consider moving more cleanup work to the undertaker, but that seems a little more involved. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25704 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b5e3c0a1ead149af5ebe1a99786fabaf871711f6 |
|
12-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added new syscalls _kern_block_thread()/_kern_unblock_thread[s](). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25469 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d648afb8d7852cc7ca9819315356ec605e2e0ee7 |
|
11-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* For each userland team the kernel creates an area in the userland address space that is fully locked and marked B_KERNEL_AREA. It can thus be accessed by the kernel without additional checks. * For each userland thread we do create a user_thread structure in that area. The structure is accessible from userland via TLS, using the private get_user_thread() function. * Introduced private userland functions [un]defer_signals(). They can be used to cheaply disable/re-enable signal delivery. They use the user_thread::defer_signals/pending_signals fields which are checked/updated by the kernel. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25451 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4d3680aaef2029eed55f82ba246bd224bf1f15c1 |
|
10-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added timeout constant B_ABSOLUTE_REAL_TIME_TIMEOUT which specifies a timeout relative to the Epoch. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25434 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4c49f2056bbec860092e8c26520398b4121f8d1a |
|
08-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Changed _kern_spawn_thread() and create_thread(): Instead of individual arguments they get a single thread_creation_attributes structure now. * Added stack_address and stack_size to thread_creation_attributes, which allow to specify the stack size or the stack to be used for the new user thread. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25389 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0c615a01ae49634aaf59fbe35b3d55b3bb8890df |
|
01-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Removed old mutex implementation and renamed cutex to mutex. * Trivial adjustments of code using mutexes. Mostly removing the mutex_init() return value check. * Added mutex_lock_threads_locked(), which is called with the threads spinlock being held. The spinlock is released while waiting, of course. This function is useful in cases where the existence of the mutex object is ensured by holding the threads spinlock. * Changed the two instances in the VFS code where an IO context of another team needs to be locked to use mutex_lock_threads_locked(). Before it required a semaphore-based mutex implementation. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25283 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
8562499f441ac23a80dd89310dbf2016b681fef9 |
|
30-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced a new locking primitive I called "cutex" (sorry for the name, couldn't resist :-P). It's semantically equivalent to a mutex, but doesn't need a semaphore (it uses thread blocking and a simple queue instead). Initialization can't fail. In fact it is ready to use without initialization when living in the bss segment, also in the early boot process. It's as fast as a benaphore in cases of low lock contention, and faster otherwise. Only disadvantage is the higher immediate memory footprint of 16 bytes. * Changed how the "thread" and "threads" debugger commands list the objects they are waiting for. Cutexes are also included. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25276 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
210199c5a74c6643969153c947fef56af3ec3cea |
|
24-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Resolved {g,s}etrlimit() TODO's, i.e. moved the implementation into separate functions and made the set errno correctly. * Added RLIMIT_CORE case. We don't support core dumps, but setting them to disabled shouldn't fail anyway. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25141 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
60222c8bacdfa0dc1ea86210614436e79d7ce709 |
|
22-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Made thread_block_with_timeout_lock() more user-friendly. It allows passing 0 as timeout flags or B_INFINITE_TIMEOUT as timeout, in which case no timer will be used. * Implemented missing thread_block_with_timeout(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25104 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6cef245eca821584f07f5a13558f51ec586852e8 |
|
22-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Detemplatized ConditionVariable{Entry}. Merged them with their respective Private* base class. * Changed sigwait() and sigsuspend() to use thread_block() instead of a condition variable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25100 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
b95f6d4710855a27bec41b6fae2b064347780173 |
|
22-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced a set of functions (thread_prepare_to_block(), thread_block(), thread_unblock(),...) that allow a thread to wait for something without needing a semaphore or condition variable. It can simply block and another thread can unblock it. Supports timeouts and interrupting. Both semaphores and condition variables use this common mechanism, now. * Semaphores: - Some simplifications due to the thread blocking mechanism. - Changed locking order to sem -> thread. It was the other way around before and when introducing the wait_for_objects() support I had also introduced a situation where the locking was reverse, which could potentially cause a dead lock on SMP systems. - Instead of queueing thread structures, a semaphore queues queued_thread entries now, which are created on the stack. The thread::sem structure could thus be removed. - Added sem_entry::net_count, which is sem_entry::count plus the acquisition count of all waiting threads. This number is needed in remove_thread_from_sem() and instead of computing it there we maintain it. - Fixed remove_thread_from_sem(). It would not unblock threads, if the sem count was <= 0. - Made sem::last_acquirer unconditional. It is actually needed for sem_info::latest_holder. Fixed fill_sem_info() accordingly. - Added some optional tracing output, though only via ktrace_printf(). * Condition variables: - Could be simplified significantly through the use of the thread blocking mechanism. Removed a good deal of unnecessary code. - Moved the ConditionVariableEntry "flags" parameter from Wait() to Add(), and adjusted all places where condition variables are used accordingly. * snooze() uses thread_block_with_timeout() instead of a semaphore. * Simplified thread interrupting in the signal and user debugger code. Instead of separate functions for threads waiting on a semaphore or condititon variable, we only have a single thread_interrupt(), now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25099 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
66aac81e98b1cf8720817d87a7f1973dc976fb3e |
|
20-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
We use only a single condition variable (instead of thread different ones) for wait_for_child(), which is notified when any job control condition (child dead, stopped, continued) occurs. These events are relatively rare anyway, and it simplifies the code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25079 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ef16b3bb765a551f1d415c72ee1489db11b498fa |
|
10-Apr-2008 |
François Revol <revol@free.fr> |
Use the thread's stack size for RLIMIT_STACK, this should work even if we ever implement changing a thread's stack. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24898 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c4a7b4e09e2b6da42ccd6dbb77fad51308f4d2c8 |
|
10-Apr-2008 |
François Revol <revol@free.fr> |
Report the stack size from getrlimit(), we might want to get fancier later but that should be enough. Tcl will want that. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24893 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
758962ec3b8fe7a5d9c7463fb5d22c469734b527 |
|
26-Mar-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added arch_debug_contains_call() function that returns wether or not a call chain contains a specific symbol (or address). * Added a new KDL command "calling" that you can use to get a list of threads that have a specific function in their call chain. * Removed extraneous white space. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24594 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4a7f236b07f4e59aef53a5427eebd01f50c99d00 |
|
09-Mar-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Process groups are now reference-counted. Processes in a group as well as the death entries of a deceased processes that were in this group and have not yet been reaped hold references to the group, so that it won't be deleted until the group is empty and all gone group members have been reaped. This fixes #1799 at last. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24335 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5b702e593447bfbd1549d8e75e31a659b2b69206 |
|
22-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
"thread" also prints the signal block mask, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24065 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0dd3108ca08b4ebac77328b089f0c4394438bac8 |
|
21-Feb-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Added SIGNAL_FLAG_DONT_RESTART_SYSCALL for send_signal_etc() which utilizes the THREAD_FLAG_DONT_RESTART_SYSCALL (but only in SIGCONT for now). * resume_thread() is now using that flag to be compatible with BeOS. * This fixes the Terminal hanging on close. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24045 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2efb87b92fa5f24376295079d26c0835847263e9 |
|
20-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added TODO: Process groups should live on until the process is reaped. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24042 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
4048494ce44a925d3d1e40e4ffb9abe670b4b827 |
|
17-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
axeld + bonefish: * Implemented automatic syscall restarts: - A syscall can indicate that it has been interrupted and can be restarted by setting a respective bit in thread::flags. It can store parameters it wants to be preserved for the restart in thread::syscall_restart::parameters. Another thread::flags bit indicates whether it has been restarted. - handle_signals() clears the restart flag, if the handled signal has a handler function installed and SA_RESTART is not set. Another thread flag (THREAD_FLAGS_DONT_RESTART_SYSCALL) can prevent syscalls from being restarted, even if they could be (not used yet, but we might want to use it in resume_thread(), so that we stay behaviorally compatible with BeOS). - The architecture specific syscall handler restarts the syscall, if the restart flag is set. Implemented for x86 only. - Added some support functions in the private <syscall_restart.h> to simplify the syscall restart code in the syscalls. - Adjusted all syscalls that can potentially be restarted accordingly. - _user_ioctl() sets new thread flag THREAD_FLAGS_IOCTL_SYSCALL while calling the underlying FS's/driver's hook, so that syscall restarts can also be supported there. * thread_at_kernel_exit() invokes handle_signals() in a loop now, as long as the latter indicates that the thread shall be suspended, so that after waking up signals received in the meantime will be handled before the thread returns to userland. Adjusted handle_signals() accordingly -- when encountering a suspending signal we don't check for further signals. * Fixed sigsuspend(): Suspending the thread and rescheduling doesn't result in the correct behavior. Instead we employ a temporary condition variable and interruptably wait on it. The POSIX test suite test passes, now. * Made the switch_sem[_etc]() behavior on interruption consistent. Depending on when the signal arrived (before the call or when already waiting) the first semaphore would or wouldn't be released. Now we consistently release it. * Refactored _user_{read,write}[v]() syscalls. Use a common function for either pair. The iovec version doesn't fail anymore, if anything could be read/written at all. It also checks whether a complete vector could be read/written, so that we won't skip data, if the underlying FS/driver couldn't read/write more ATM. * Some refactoring in the x86 syscall handler: The int 99 and sysenter handlers use a common subroutine to avoid code duplication. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23983 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
9835c090a69357df22aaaa5a3e12483a36f8deb0 |
|
07-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added a boolean "force" parameter to thread_yield(). When true, the function has the old behavior. When false, it just calls the scheduler without any priority adjustment or other stuff. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23906 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2362422c380214b6274ba057d84ddc9fc4640e90 |
|
03-Feb-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Do not just overwrite the thread state when suspending a thread since this easily causes problems on SMP systems (triggers the panic in the scheduler). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23839 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7694461ea6a9440056a79ea8ac8cd36bc563f07b |
|
28-Jan-2008 |
Marcus Overhagen <marcusoverhagen@gmail.com> |
Use decimal for thread ids. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23779 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
62c35bb99ac3711a47e82e87ade3b726387cdbde |
|
26-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Corrected "threads" usage text. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23756 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
f2e758e5da257ec3cab4a1f93f8f1dbcaea81c36 |
|
26-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added usage message for the thread-related debugger commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23750 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6761f5a660bcba247e0967e09ac58f2f4488bd55 |
|
25-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Move the handling of still running threads into scheduler_enqueue_in_run_queue(). This should be in line with all uses of scheduler_enqueue_in_run_queue() and simplifies a few places where it is used. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23738 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
46cb5cfdd3ad5c8631447344267f9f5591ecb5e3 |
|
18-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
When a main thread (i.e. a team) dies, we have to send the SIGCHLD to its parent while still holding the team spinlock. We were racing with wait_for_child(), since after the child invoked team_set_job_control_state(), the parent thread could continue as soon as the team spinlock was released. The SIGCHLD could thus arrive way later and interrupt another syscall. This could be reproduced with the compile_bench.sh script from time to time: When interrupted while waiting for the next subprocess, the gcc frontend would delete a still needed temporary file. The whole thing is actually only a problem, because we don't support automatic syscall restarts yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23625 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
34b3b26b3b8c46ba46ddde037b10dd173f4936d6 |
|
10-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged branch haiku/branches/developer/bonefish/optimization revision 23139 into trunk, with roughly the following changes (for details svn log the branch): * The int 99 syscall handler is now fully in assembly. * Added a sysenter/sysexit handler and use it on Pentiums that support it (via commpage). * Got rid of i386_handle_trap(). A bit of functionality was moved into the assembly handler which now uses a jump table to call C functions handling the respective interrupt. * Some optimizations to get user debugger support code out of the interrupt handling path. * Introduced a thread::flags fields which allows to skip handling of rare events (signals, user debug enabling/disabling) on the common interrupt handling path. * Got rid of the explicit iframe stack. The iframes can still be retrieved by iterating through the stack frames. * Made the commpage an architecture independent feature. It's used for the real time data stuff (instead of creating a separate area). * The x86 CPU modules can now provide processor optimized versions for common functions (currently memcpy() only). They are used in the kernel and are provided to the userland via commpage entries. * Introduced build system feature allowing easy use of C structure member offsets in assembly code. Changes after merging: * Fixed merge conflict in src/system/kernel/arch/x86/arch_debug.cpp (caused by refactoring and introduction of "call" debugger command). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23370 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
92ab20b3a4994eca38234479d344e80519019652 |
|
27-Nov-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added a list of death_entry's to the teams structure. It stores the exit status of (non-main) threads of a team. Fixes bug #1644. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23009 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
d4fc2b7db779647aed0ff248d21527146e8e2bcd |
|
18-Nov-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Fixed a bug reported by Ryan: the stack_end pointer of a thread was reported one too low in comparison with BeOS (ie. the end pointer was inclusive, now it's exclusive). * Moved static functions fill_thread_info(), and {send|receive}_data_etc() to the private function section. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22945 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
00ef60f643bb0b3c4f57a75949d70060905bb70d |
|
12-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
Removed the "next_*" in queue debugger commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22514 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
90bab16d16aa995fc2a04a90a782d8798e1260fc |
|
11-Oct-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* IDs are now generally written as decimal numbers, rather than hexadecimal. * Fixed warnings with debug output turned on. * Shuffled functions around a bit. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22504 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
636bfc08aeaaa7f1bab813c5aa2e8e666b40ec64 |
|
02-Oct-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Renamed fs/vfs_select.cpp to wait_for_objects.cpp and got rid of vfs_select.h, respectively moved most of it into the new kernel private header wait_for_objects.h. * Added new experimental API functions wait_for_objects[_etc](). They work pretty much like poll(), but also for semaphores, ports, and threads. * Removed the "ref" parameter from notify_select_events() and the select_sync_pool functions as well as from fd_ops::fd_[de]select(). It is no longer needed. The FS interface select() hook still has it, though -- the VFS will always pass 0. * de]select_fd() take a select_info* instead of a select_sync* + ref pair, now. Added respective functions for semaphores, ports, and threads. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22416 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
3c3674113fe25de062977e6ebd4115e26f79d89f |
|
01-Oct-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Fixed a race condition on thread exit: There was a gap between releasing the death stack and reacquiring the thread lock in which another thread could snatch our stack that we were still going to use for the scheduler. Now we've got a second spinlock that we can hold while releasing a semaphore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22403 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5c4ed86b56868e2584298c05792a6e65d4d3fa78 |
|
27-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* Moved some definitions from vm_types.h that functions in vm.h need as arguments into vm.h. * This should fix the broken build from earlier - thanks Stefano for the note! * That also allowed to clean some other includes a bit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22331 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e6dc7903e4277bf6e22527ed611df619c7e645f1 |
|
26-Sep-2007 |
Axel Dörfler <axeld@pinc-software.de> |
* vm.h no longer includes vm_types.h - only those that actually need access to the private VM types are including vm_types.h now. * Removed vm_page, vm_area, vm_cache, and vm_address_space typedefs; it's cleaner this way, and the actual types are only used in C++ files now, anyway. * And that caused changes in many files... * Made commpage.h self-containing. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22329 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
24bcf55926212cfc26ffbed2cb71fe3ca2b99c68 |
|
27-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Introduced new job_control_entry structure which, among other things, is used instead of death_entry for team::dead_children. * Added team::{stopped,continued}_children, which, analoguously to dead_children, are used to track the state of stopped/continued children. * A team does have a job_control_entry, which is allocated at team creation time. It will be inserted into the parent's {stopped,continued}_children lists as the team's main thread is stopped/continued and removed when waitpid() retrieves the child state. When the team dies the entry is detached from the team and goes into the parent's dead_children list. * Removed the wait_for_any field from team_dead_children. It was solely used to avoid deletion of the contained entries in certain situations. wait_for_child() (the waitpid() backend) always deletes an entry now, regardless of whether other threads are waiting; that's in accordance with the waidpid() specification. wait_for_thread() removes the entry only, if the caller is the parent of the respective team. * Introduced team_set_job_control_state() which performes the job control entry transitions between the respective lists and wakes up threads waiting in wait_for_child(). It is invoked on team death and when the team's main thread receives job control signals. * Reorganized wait_for_child(). It handles WCONTINUED and WUNTRACED now, too. Removed a block that interpreted the supplied ID as thread ID. * Added missing parts in waitpid(). Job control starts to work, though it seems to have some glitches. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22088 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ff895459b795520dddd83f77c7460ba7810e3c87 |
|
27-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Replaced the team::dead_children::sem semaphore by a condition variable. Due to C code including the header I had to turn it from and aggregated member to a pointer. I'm very close to starting to convert all remaining .c to .cpp files. :-/ * Got rid of the "waiters" field. It was only written, never read. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22084 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ff308b0b491531f2f3b5d22244d7ac5904133e61 |
|
26-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Condition variables changes: * Removed left-over commented C implementation. * It is now possible for a thread to wait for more than one condition variable at a time. * Made waiting for condition variables optionally interruptable. * Renamed Notify() method to NotifyAll() and added a NotifyOne(), so that it is now possible to wake up only one of the waiting threads. Pretty much untested at the moment. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22081 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
61b50eed279a53db5b222b91271f8866ab9c1e0e |
|
26-Aug-2007 |
Jérôme Duval <korli@users.berlios.de> |
fix gcc4 build git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22080 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ebe6d106843e4280c58c87eaa1eab9b71ece8c2a |
|
26-Aug-2007 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Turned the files I intend to devastate to C++. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22074 a95241bf-73f2-0310-859d-f6bbb57e9c96
|