#
daf1dd9c |
|
28-Nov-2023 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/sem: Use "count" as thread_unblock status in B_RELEASE_ALL. Previously, "count" did nothing for B_RELEASE_ALL. Now, if it is < 0, it will be the error code returned by acquire_sem() of any waiting threads. As B_RELEASE_ALL is a Haiku extension, this change should not cause any compatibility problems that we cannot fix. This will be useful in implementing some features of TUN/TAP with network FIFOs. Change-Id: I2dbccedefac2024fe740b87543ff3b80f5257e20 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7163 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
87bdc2b0 |
|
05-Aug-2019 |
Adrien Destugues <pulkomandy@pulkomandy.tk> |
fix dumping semaphores by name There was no check for strtoul success or failure (it returns 0 on failure but that is also a valid conversion result). Detect if endptr has been advanced instead (meaning there were some parsed characters in strtoul so the argument at least starts with a number) Change-Id: Ieefbd57a250ddcdb9362094389151c2a432e4c73 Reviewed-on: https://review.haiku-os.org/c/1683 Reviewed-by: Rene Gollent <rene@gollent.com>
|
#
698c471f |
|
22-Jul-2019 |
waddlesplash <waddlesplash@gmail.com> |
kernel/sem: Restore interrupts-unlock before free().
|
#
0a564c2c |
|
20-Jul-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/sem: Drop GRAB macros in favor of SpinLockers. No functional change intended. Change-Id: I24f6f8c55b18f8d031d0b5a87672cc969e141577 Reviewed-on: https://review.haiku-os.org/c/1636 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
|
#
1eededf1 |
|
17-Feb-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Only sanity-check interrupts in switch_sem_etc under KDEBUG. "are_interrupts_enabled()" is a "relatively" expensive function, so avoiding it makes sense. This is the same way it's done elsewhere in sem.cpp, as well as for mutexes and condition variables also.
|
#
f8ea9ed5 |
|
15-Jan-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel/sem: Fix -Wformat.
|
#
2e33d79d |
|
07-Jan-2019 |
Augustin Cavalier <waddlesplash@gmail.com> |
kernel: Panic on attempting to release a semaphore with interrupts disabled... ... and B_DO_NOT_RESCHEDULE unset. We already have equivalent panics for mutexes and condition variables, so it seems to make sense to check for this too. There have been some bug reports recently about hard deadlocks with symptoms (i.e. kernel debugger can't even be summoned) that match "interrupt handler thread was context-switched while holding interrupt lock," and this is the only major remaining path to that without such a check. This would have also helped me with recent FreeBSD driver porting; I forgot to pass the flag once and deadlocked my system in precisely this manner.
|
#
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.
|
#
11cacd0c |
|
04-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove thread_block_with_timeout_locked()
|
#
c8dd9f77 |
|
29-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Add thread_unblock() and use it where possible
|
#
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.
|
#
b7b5d763 |
|
17-Dec-2012 |
Sergei Reznikov <diver@gelios.net> |
64-bit fixes for kernel with KDEBUG_LEVEL = 0 Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
|
#
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.
|
#
0e88a887 |
|
13-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
First round of 64-bit safety fixes in the kernel. * Most of this is incorrect printf format strings. Changed all strings causing errors to use the B_PRI* format string definitions, which means the strings should be correct across all platforms. * Some other fixes for errors, casts required, etc.
|
#
c83bde41 |
|
05-Apr-2012 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
switch_sem_etc(): Unbreak the actual switch case The scheduler lock was still being held when release_sem_etc() was called. The bug was introduced in 24df65921befcd0ad0c5c7866118f922da61cb96. Fixes #8448.
|
#
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
|
#
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
|
#
5e2ed2f3 |
|
07-Aug-2010 |
Stefano Ceccherini <stefano.ceccherini@gmail.com> |
tempName was leaked in case team was NULL. CID 1702 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37970 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
|
#
7198f765 |
|
05-May-2010 |
Axel Dörfler <axeld@pinc-software.de> |
* During early kernel startup, we must not create areas without the CREATE_AREA_DONT_WAIT flag; waiting at this point is not allowed. * I hope I found all occurences, but there might be some areas left (note, only those that don't use B_ALREADY_WIRED are problematic). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36624 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
|
#
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
|
#
07d45563 |
|
16-Nov-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Change get_next_sem_info() to be index based, not ID based - the semaphore IDs aren't monotonically increasing which this code was assuming. This fixes bug #4917. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34074 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0087f940 |
|
26-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* sem_entry no contains a pointer to the owning team, instead of only its ID. * Accidently, this should also fix bug #4839. * Optimized _get_next_sem_info() a whole lot by iterating over the team's semaphore list. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33773 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
07e9fd1d |
|
26-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* sem_delete_owned_sems() now grabs the team lock for a very short time, and once only. * Improved missing team warning. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33770 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ddbe1200 |
|
22-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Semaphores are now put into the team struct in a doubly linked list. * This makes sem_delete_owned_sems() a lot more efficient; before it would need to scan the entire semaphore table. * This speeds up the test build of the kernel by another 2 seconds (with KDEBUG=2) on my laptop. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33743 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
|
#
227fe7d3 |
|
23-Apr-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Scheduler/wait object listener: - Moved scheduler listening interface to <listeners.h> and added more convenient to use templatized notification functions. - Added a listener mechanism for the wait objects (semaphores, condition variables, mutex, rw_lock). * system profiler: - Hopefully fixed locking issues related to notifying the profiler thread for good. We still had an inconsistent locking order, since the scheduler notification callbacks are invoked with the thread lock held and have to acquire the object lock then, while the other callbacks acquired the object lock first and as a side effect of ConditionVariable::NotifyOne() acquired the thread lock. Now we make sure the object lock is the innermost lock. - Track the number of dropped events due to a full buffer. _user_system_profiler_next_buffer() returns this count now. - When scheduling profiling events are requested also listen to wait objects and generate the respective profiling events. We send those events lazily and cache the infos to avoid resending an event for the same wait object. - When starting profiling we do now generate "thread scheduled" events for the already running threads. - _user_system_profiler_start(): Check whether the parameters pointer is a userland address at all. - The system_profiler_team_added event does now also contain the team's name. * Added a sem_get_name_unsafe() returning a semaphore's name. It is "unsafe", since the caller has to ensure that the semaphore exists and continues to exist as long as the returned name is used. * Adjusted the "profile" and "scheduling_recorder" according to the system profiling changes. The latter prints the number of dropped events, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30345 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c8b762e4 |
|
20-Mar-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Userland applications can no longer delete kernel semaphores. However, they are still allowed to delete semaphores of other teams... * Anyway, this fixes bug #3585. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29621 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
209c0f49 |
|
23-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
0 is a valid semaphore ID. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28292 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
59dbd26f |
|
20-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved more debug macros to kernel_debug_config.h. * Turned the checks for all those macros to "#if"s instead of "#ifdef"s. * Introduced macro KDEBUG_LEVEL which serves as a master setting. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28248 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
537d0818 |
|
03-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
release_sem_etc(): Reschedule only when a thread with a priority greater than that of the current thread has been woken up. I didn't see the reason why the thread should otherwise relinquish the rest of its quantum. I noticed for instance that client and app server window threads were ping-ponging more than seemed necessary. In most cases when the client sent a port message it would be unscheduled although it had run only for a few microseconds and had still stuff to do. I measured a relatively Terminal-heavy "find /boot" (second run), which does now take 5-10% less time. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27314 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
020ac568 |
|
03-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Fixed bug in the "scheduler" command: The check when a thread was unscheduled was incorrect. * Introduced _kern_analyze_scheduling() syscall. It requires scheduler kernel tracing to be enabled. It uses the tracing entries for a given period of time to do a similar analysis the "scheduler" debugger command does (i.e. number of runs, run time, latencies, preemption times) for each thread. Additionally the analysis includes for each thread how long the thread waited on each locking primitive in total. * Added kernel tracing for the creation of semaphores and initialization of condition variables, mutexes, and rw locks. The enabling macro is SCHEDULING_ANALYSIS_TRACING. The only purpose is to provide _kern_analyze_scheduling() with more info on the locking primitives (the name in particular). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27304 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6bf26da2 |
|
02-Aug-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed sem_spinlock to sSemsSpinlock. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26732 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
27245755 |
|
02-Aug-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed kernel_startup to gKernelStartup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26731 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
|
#
5c99d639 |
|
22-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged branch haiku/branches/developer/bonefish/vm into trunk. This introduces the following relevant changes: * VMCache: - Renamed vm_cache to VMCache, merged it with vm_store and made it a C++ class with virtual methods (replacing the store operations). Turned the different store implementations into subclasses. - Introduced MergeStore() callback, changed semantics of Commit(). - Changed locking and referencing semantics. A reference can only be acquired/released with the cache locked. An unreferenced cache is deleted and a mergeable cache merged when it is unlocked. This removes the "busy" state of a cache and simplifies the page fault code. * Added VMAnonymousCache, which will implement swap support (work by Zhao Shuai). It is not integrated and used yet, though. * Enabled the mutex/recursive lock holder asserts. * Fixed DoublyLinkedList::Swap(). * Generalized the low memory handler to a low resource handler. And made semaphores and reserved memory handled resources. Made vm_try_resource_memory() optionally wait (with timeout), and used that feature to reserve memory for areas. ... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26572 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
|
#
5142c2ac |
|
05-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added support for POSIX semaphores (the ones from the XSI extension Realtime option group). The implementation should be complete, but is totally untested yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25326 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e225a906 |
|
24-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
With my recent changes release_sem_etc() accidentally lost the cleverness to reschedule only, if it actually unblocked another thread. Should have been the reason for #2152 (overall slowdown). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25131 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
|
#
037f7094 |
|
09-Apr-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Cleaned up KernelExport.h completely, removed deprecated and non implemented API, uses the _PRINTFLIKE macro where appropriate. * Got rid of the "qent" structure, struct timer now contains everything we need. This makes the affected code in sem.cpp, signal.cpp, and timer.c much cleaner, and resolves a few TODOs. * Minor cleanup in vfs.cpp. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24871 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
20e4f92c |
|
23-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
switch_sem_etc() doesn't check the return value of add_timer(), hence we need to make sure that we never get that far with a negative timeout or we'll wait forever. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24083 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
|
#
c486dde9 |
|
28-Jan-2008 |
Marcus Overhagen <marcusoverhagen@gmail.com> |
cosmetic git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23778 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
36b55f46 |
|
26-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Don't panic in case a thread is not in the wait queue of a sem anymore. On SMP systems it can easily happen that the thread gets removed from the queue (when it times out for example) during the time we don't hold the sem lock. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23749 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1b0e74fc |
|
26-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Don't clobber the thread variable as we use it again. Since it always is NULL at the end of that loop we guaranteed a crash when this special handling was triggered. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23748 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7e80cf00 |
|
25-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Missed this setting of thread state which is now unnecessary. Otherwise nothing in the kernel seems to mess with the state outside of the scheduler so checking for B_THREAD_RUNNING there should be fine. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23740 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
|
#
d9256509 |
|
25-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Apply the same logic as in r23731 to all other places in the semaphore code where threads are enqueued into the run queue. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23733 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2f3f3d79 |
|
25-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Fix the underlying problem that caused the issue of running threads being enqueued into the run_queue again. Modified the workaround to a panic in the scheduler so we notice when something else does the same. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23731 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5aee691e |
|
17-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
The "sem" and "port" debugger commands set some temporary variables, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23595 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ce637fda |
|
17-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added usage (respectively more detailed usage) messages for "sem", "sems", "port", and "ports" debugger commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23586 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
224aee3f |
|
17-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
sem.c -> sem.cpp, port.c -> port.cpp git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23585 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
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.
|
#
11cacd0c1345cd3296f12e07d18996a2c7572a64 |
|
04-Nov-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Remove thread_block_with_timeout_locked()
|
#
c8dd9f7780c426e592a3ccb231e6bfab51f15eb9 |
|
29-Oct-2013 |
Pawel Dziepak <pdziepak@quarnos.org> |
kernel: Add thread_unblock() and use it where possible
|
#
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.
|
#
b7b5d7636b96de53bb4327684cc1843e56f62320 |
|
17-Dec-2012 |
Sergei Reznikov <diver@gelios.net> |
64-bit fixes for kernel with KDEBUG_LEVEL = 0 Signed-off-by: Alex Smith <alex@alex-smith.me.uk>
|
#
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.
|
#
0e88a887b4a9ecaaf1062078d9ca9bfca78fcf3a |
|
13-Jun-2012 |
Alex Smith <alex@alex-smith.me.uk> |
First round of 64-bit safety fixes in the kernel. * Most of this is incorrect printf format strings. Changed all strings causing errors to use the B_PRI* format string definitions, which means the strings should be correct across all platforms. * Some other fixes for errors, casts required, etc.
|
#
c83bde410aa07480175ab2b0743c35da9a0572bb |
|
05-Apr-2012 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
switch_sem_etc(): Unbreak the actual switch case The scheduler lock was still being held when release_sem_etc() was called. The bug was introduced in 24df65921befcd0ad0c5c7866118f922da61cb96. Fixes #8448.
|
#
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
|
#
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
|
#
5e2ed2f356cdf9ddb7d76be1392b7f88b7a6f072 |
|
07-Aug-2010 |
Stefano Ceccherini <stefano.ceccherini@gmail.com> |
tempName was leaked in case team was NULL. CID 1702 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37970 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
|
#
7198f76564e4b062401bb95f6ddf540bbf9e8625 |
|
05-May-2010 |
Axel Dörfler <axeld@pinc-software.de> |
* During early kernel startup, we must not create areas without the CREATE_AREA_DONT_WAIT flag; waiting at this point is not allowed. * I hope I found all occurences, but there might be some areas left (note, only those that don't use B_ALREADY_WIRED are problematic). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36624 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
|
#
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
|
#
07d455634689a48ad5e3c1289dd6773a274e58bd |
|
16-Nov-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Change get_next_sem_info() to be index based, not ID based - the semaphore IDs aren't monotonically increasing which this code was assuming. This fixes bug #4917. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34074 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
0087f9409bdd85d996c69c0a0cdb9a35b478abef |
|
26-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* sem_entry no contains a pointer to the owning team, instead of only its ID. * Accidently, this should also fix bug #4839. * Optimized _get_next_sem_info() a whole lot by iterating over the team's semaphore list. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33773 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
07e9fd1d8427a325a8637e3108633023b56b41cc |
|
26-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* sem_delete_owned_sems() now grabs the team lock for a very short time, and once only. * Improved missing team warning. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33770 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ddbe12007a455315c7904deeea339dc8827c66ad |
|
22-Oct-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Semaphores are now put into the team struct in a doubly linked list. * This makes sem_delete_owned_sems() a lot more efficient; before it would need to scan the entire semaphore table. * This speeds up the test build of the kernel by another 2 seconds (with KDEBUG=2) on my laptop. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33743 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
|
#
227fe7d34aeed45d0727a0abde2ea2309352983b |
|
23-Apr-2009 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Scheduler/wait object listener: - Moved scheduler listening interface to <listeners.h> and added more convenient to use templatized notification functions. - Added a listener mechanism for the wait objects (semaphores, condition variables, mutex, rw_lock). * system profiler: - Hopefully fixed locking issues related to notifying the profiler thread for good. We still had an inconsistent locking order, since the scheduler notification callbacks are invoked with the thread lock held and have to acquire the object lock then, while the other callbacks acquired the object lock first and as a side effect of ConditionVariable::NotifyOne() acquired the thread lock. Now we make sure the object lock is the innermost lock. - Track the number of dropped events due to a full buffer. _user_system_profiler_next_buffer() returns this count now. - When scheduling profiling events are requested also listen to wait objects and generate the respective profiling events. We send those events lazily and cache the infos to avoid resending an event for the same wait object. - When starting profiling we do now generate "thread scheduled" events for the already running threads. - _user_system_profiler_start(): Check whether the parameters pointer is a userland address at all. - The system_profiler_team_added event does now also contain the team's name. * Added a sem_get_name_unsafe() returning a semaphore's name. It is "unsafe", since the caller has to ensure that the semaphore exists and continues to exist as long as the returned name is used. * Adjusted the "profile" and "scheduling_recorder" according to the system profiling changes. The latter prints the number of dropped events, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30345 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
c8b762e456822d2840626b29b80640b95f349a36 |
|
20-Mar-2009 |
Axel Dörfler <axeld@pinc-software.de> |
* Userland applications can no longer delete kernel semaphores. However, they are still allowed to delete semaphores of other teams... * Anyway, this fixes bug #3585. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29621 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
209c0f495ecf4a9040fdd517840012f01f486030 |
|
23-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
0 is a valid semaphore ID. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28292 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
59dbd26f5f41a6c1272f6cac9c8cda4b19b79097 |
|
20-Oct-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Moved more debug macros to kernel_debug_config.h. * Turned the checks for all those macros to "#if"s instead of "#ifdef"s. * Introduced macro KDEBUG_LEVEL which serves as a master setting. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28248 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
537d0818170525281422c4a5c31ef7ae887eb377 |
|
03-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
release_sem_etc(): Reschedule only when a thread with a priority greater than that of the current thread has been woken up. I didn't see the reason why the thread should otherwise relinquish the rest of its quantum. I noticed for instance that client and app server window threads were ping-ponging more than seemed necessary. In most cases when the client sent a port message it would be unscheduled although it had run only for a few microseconds and had still stuff to do. I measured a relatively Terminal-heavy "find /boot" (second run), which does now take 5-10% less time. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27314 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
020ac568404b8ab78825622d8815be48e987f649 |
|
03-Sep-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
* Fixed bug in the "scheduler" command: The check when a thread was unscheduled was incorrect. * Introduced _kern_analyze_scheduling() syscall. It requires scheduler kernel tracing to be enabled. It uses the tracing entries for a given period of time to do a similar analysis the "scheduler" debugger command does (i.e. number of runs, run time, latencies, preemption times) for each thread. Additionally the analysis includes for each thread how long the thread waited on each locking primitive in total. * Added kernel tracing for the creation of semaphores and initialization of condition variables, mutexes, and rw locks. The enabling macro is SCHEDULING_ANALYSIS_TRACING. The only purpose is to provide _kern_analyze_scheduling() with more info on the locking primitives (the name in particular). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27304 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
6bf26da22824059d3ce1fde70188fea1d6ce2082 |
|
02-Aug-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed sem_spinlock to sSemsSpinlock. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26732 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
272457553e0ff0860cf931c1d193c2c6020a7da8 |
|
02-Aug-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Renamed kernel_startup to gKernelStartup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26731 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
|
#
5c99d639708df9b4e2cc847b38d510149d19ec78 |
|
22-Jul-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Merged branch haiku/branches/developer/bonefish/vm into trunk. This introduces the following relevant changes: * VMCache: - Renamed vm_cache to VMCache, merged it with vm_store and made it a C++ class with virtual methods (replacing the store operations). Turned the different store implementations into subclasses. - Introduced MergeStore() callback, changed semantics of Commit(). - Changed locking and referencing semantics. A reference can only be acquired/released with the cache locked. An unreferenced cache is deleted and a mergeable cache merged when it is unlocked. This removes the "busy" state of a cache and simplifies the page fault code. * Added VMAnonymousCache, which will implement swap support (work by Zhao Shuai). It is not integrated and used yet, though. * Enabled the mutex/recursive lock holder asserts. * Fixed DoublyLinkedList::Swap(). * Generalized the low memory handler to a low resource handler. And made semaphores and reserved memory handled resources. Made vm_try_resource_memory() optionally wait (with timeout), and used that feature to reserve memory for areas. ... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26572 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
|
#
5142c2ac86c0f020ffa3fc31cea9f1f2f1b6ef91 |
|
05-May-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added support for POSIX semaphores (the ones from the XSI extension Realtime option group). The implementation should be complete, but is totally untested yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25326 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
e225a906d2ac4e4f4a22d3787265c5124ed8e2b4 |
|
24-Apr-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
With my recent changes release_sem_etc() accidentally lost the cleverness to reschedule only, if it actually unblocked another thread. Should have been the reason for #2152 (overall slowdown). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25131 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
|
#
037f70947f14b7e7d452543ad645f38d7c96f6eb |
|
09-Apr-2008 |
Axel Dörfler <axeld@pinc-software.de> |
* Cleaned up KernelExport.h completely, removed deprecated and non implemented API, uses the _PRINTFLIKE macro where appropriate. * Got rid of the "qent" structure, struct timer now contains everything we need. This makes the affected code in sem.cpp, signal.cpp, and timer.c much cleaner, and resolves a few TODOs. * Minor cleanup in vfs.cpp. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24871 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
20e4f92cf540b33a55c36a414b63057b948417dc |
|
23-Feb-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
switch_sem_etc() doesn't check the return value of add_timer(), hence we need to make sure that we never get that far with a negative timeout or we'll wait forever. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24083 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
|
#
c486dde9d67280f29dd0f24a34aae6fc71926c13 |
|
28-Jan-2008 |
Marcus Overhagen <marcusoverhagen@gmail.com> |
cosmetic git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23778 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
36b55f46942a4cb38e23b1130885b5f82e4d6772 |
|
26-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Don't panic in case a thread is not in the wait queue of a sem anymore. On SMP systems it can easily happen that the thread gets removed from the queue (when it times out for example) during the time we don't hold the sem lock. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23749 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
1b0e74fc1884bb49d4aed74395abc120d98f89fc |
|
26-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Don't clobber the thread variable as we use it again. Since it always is NULL at the end of that loop we guaranteed a crash when this special handling was triggered. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23748 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
7e80cf009622e5ade1f87703c0ad3e9a17cd4a80 |
|
25-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Missed this setting of thread state which is now unnecessary. Otherwise nothing in the kernel seems to mess with the state outside of the scheduler so checking for B_THREAD_RUNNING there should be fine. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23740 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
|
#
d92565096840c6248cc435ebfc662432a3b5c252 |
|
25-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Apply the same logic as in r23731 to all other places in the semaphore code where threads are enqueued into the run queue. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23733 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
2f3f3d79b5dff34f0ca64bf38db332bf2d8caa09 |
|
25-Jan-2008 |
Michael Lotz <mmlr@mlotz.ch> |
Fix the underlying problem that caused the issue of running threads being enqueued into the run_queue again. Modified the workaround to a panic in the scheduler so we notice when something else does the same. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23731 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
5aee691ed843815dab1736dc5eb77d9cd20ea1ef |
|
17-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
The "sem" and "port" debugger commands set some temporary variables, now. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23595 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
ce637fda24b5c07f99236db30b2f9086d77317bb |
|
17-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
Added usage (respectively more detailed usage) messages for "sem", "sems", "port", and "ports" debugger commands. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23586 a95241bf-73f2-0310-859d-f6bbb57e9c96
|
#
224aee3ffc83a306629696fe4cf45cad9efa4349 |
|
17-Jan-2008 |
Ingo Weinhold <ingo_weinhold@gmx.de> |
sem.c -> sem.cpp, port.c -> port.cpp git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23585 a95241bf-73f2-0310-859d-f6bbb57e9c96
|