summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sig.c
Commit message (Collapse)AuthorAgeFilesLines
* Reversion of commit by Davidxu plus fixes since applied.julian2003-02-011-0/+6
| | | | | | | | I'm not convinced there is anything major wrong with the patch but them's the rules.. I am using my "David's mentor" hat to revert this as he's offline for a while.
* No longer force COMPAT_FREEBSD4 to be on.peter2003-01-271-3/+0
|
* Move UPCALL related data structure out of kse, introduce a newdavidxu2003-01-261-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | data structure called kse_upcall to manage UPCALL. All KSE binding and loaning code are gone. A thread owns an upcall can collect all completed syscall contexts in its ksegrp, turn itself into UPCALL mode, and takes those contexts back to userland. Any thread without upcall structure has to export their contexts and exit at user boundary. Any thread running in user mode owns an upcall structure, when it enters kernel, if the kse mailbox's current thread pointer is not NULL, then when the thread is blocked in kernel, a new UPCALL thread is created and the upcall structure is transfered to the new UPCALL thread. if the kse mailbox's current thread pointer is NULL, then when a thread is blocked in kernel, no UPCALL thread will be created. Each upcall always has an owner thread. Userland can remove an upcall by calling kse_exit, when all upcalls in ksegrp are removed, the group is atomatically shutdown. An upcall owner thread also exits when process is in exiting state. when an owner thread exits, the upcall it owns is also removed. KSE is a pure scheduler entity. it represents a virtual cpu. when a thread is running, it always has a KSE associated with it. scheduler is free to assign a KSE to thread according thread priority, if thread priority is changed, KSE can be moved from one thread to another. When a ksegrp is created, there is always N KSEs created in the group. the N is the number of physical cpu in the current system. This makes it is possible that even an userland UTS is single CPU safe, threads in kernel still can execute on different cpu in parallel. Userland calls kse_create to add more upcall structures into ksegrp to increase concurrent in userland itself, kernel is not restricted by number of upcalls userland provides. The code hasn't been tested under SMP by author due to lack of hardware. Reviewed by: julian
* Forgot to call setrunnable() for un-idled thread.davidxu2003-01-071-0/+1
|
* Check signals for idled threads.davidxu2003-01-071-2/+2
|
* Add code to ddb to allow backtracing an arbitrary thread.julian2002-12-281-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | (show thread {address}) Remove the IDLE kse state and replace it with a change in the way threads sahre KSEs. Every KSE now has a thread, which is considered its "owner" however a KSE may also be lent to other threads in the same group to allow completion of in-kernel work. n this case the owner remains the same and the KSE will revert to the owner when the other work has been completed. All creations of upcalls etc. is now done from kse_reassign() which in turn is called from mi_switch or thread_exit(). This means that special code can be removed from msleep() and cv_wait(). kse_release() does not leave a KSE with no thread any more but converts the existing thread into teh KSE's owner, and sets it up for doing an upcall. It is just inhibitted from being scheduled until there is some reason to do an upcall. Remove all trace of the kse_idle queue since it is no-longer needed. "Idle" KSEs are now on the loanable queue.
* Don't cast a pointer to (intptr_t) and then on to (int) when we cannotphk2002-12-171-3/+3
| | | | | be sure that (int) is large enough. Instead cast only to (intptr_t) and cast the switch/case values to (intptr_t) as well.
* Split 4.x and 5.x signal handling so that we can keep 4.x signalpeter2002-10-251-4/+73
| | | | | | | | | | | | | | | | handling clean and functional as 5.x evolves. This allows some of the nasty bandaids in the 5.x codepaths to be unwound. Encapsulate 4.x signal handling under COMPAT_FREEBSD4 (there is an anti-foot-shooting measure in place, 5.x folks need this for a while) and finish encapsulating the older stuff under COMPAT_43. Since the ancient stuff is required on alpha (longjmp(3) passes a 'struct osigcontext *' to the current sigreturn(2), instead of the 'ucontext_t *' that sigreturn is supposed to take), add a compile time check to prevent foot shooting there too. Add uniform COMPAT_43 stubs for ia64/sparc64/powerpc. Tested on: i386, alpha, ia64. Compiled on sparc64 (a few days ago). Approved by: re
* Fix mis-indentation.phk2002-10-021-1/+1
| | | | Spotted by: FlexeLint
* Back our kernel support for reliable signal queues.jmallett2002-10-011-36/+28
| | | | Requested by: rwatson, phk, and many others
* Back out code changes that snuck into the previous forced commit.jmallett2002-10-011-9/+4
|
* (Forced commit, to clarify previous commit of ksiginfo/signal queue code.)jmallett2002-10-011-4/+9
| | | | | | | | | | | | | | | I've added a structure, kernel-private, to represent a pending or in-delivery signal, called `ksiginfo'. It is roughly analogous to the basic information that is exported by the POSIX interface 'siginfo_t', but more basic. I've added functions to allocate these structures, and further to wrap all signal operations using them. Once the operations are wrapped, I've added a TailQ (see queue(3)) of these structures to 'struct proc', and all pending signals are in that TailQ. When a signal is being delivered, it is dequeued from the list. Once I finish the spreading of ksiginfo throughout the tree, the dequeued structure will be delivered to the process in question, whereas currently and normally, the signal number is what is used.
* First half of implementation of ksiginfo, signal queues, and such. Thisjmallett2002-09-301-28/+36
| | | | | | | | | | | | | | | | | | | | | | gets signals operating based on a TailQ, and is good enough to run X11, GNOME, and do job control. There are some intricate parts which could be more refined to match the sigset_t versions, but those require further evaluation of directions in which our signal system can expand and contract to fit our needs. After this has been in the tree for a while, I will make in kernel API changes, most notably to trapsignal(9) and sendsig(9), to use ksiginfo more robustly, such that we can actually pass information with our (queued) signals to the userland. That will also result in using a struct ksiginfo pointer, rather than a signal number, in a lot of kern_sig.c, to refer to an individual pending signal queue member, but right now there is no defined behaviour for such. CODAFS is unfinished in this regard because the logic is unclear in some places. Sponsored by: New Gold Technology Reviewed by: bde, tjr, jake [an older version, logic similar]
* Fix style nit where conditionally compiled code was unconditionalized,obrien2002-09-291-2/+1
| | | | | | but style(9) was consulted. Submitted by: bde
* Be consistent about "static" functions: if the function is markedphk2002-09-281-1/+1
| | | | | | static in its prototype, mark it static at the definition too. Inspired by: FlexeLint warning #512
* Add kernel support needed for the KSE-aware libpthread:mini2002-09-161-0/+3
| | | | | | | | | | | | - Use ucontext_t's to store KSE thread state. - Synthesize state for the UTS upon each upcall, rather than saving and copying a trapframe. - Deliver signals to KSE-aware processes via upcall. - Rename kse mailbox structure fields to be more BSD-like. - Store the UTS's stack in struct proc in a stack_t. Reviewed by: bde, deischen, julian Approved by: -arch
* Allocate KSEs and KSEGRPs separatly and remove them from the proc structure.julian2002-09-151-1/+8
| | | | | | | | | next step is to allow > 1 to be allocated per process. This would give multi-processor threads. (when the rest of the infrastructure is in place) While doing this I noticed libkvm and sys/kern/kern_proc.c:fill_kinfo_proc are diverging more than they should.. corrective action needed soon.
* Completely redo thread states.julian2002-09-111-12/+12
| | | | Reviewed by: davidxu@freebsd.org
* s/SGNL/SIG/davidxu2002-09-051-3/+3
| | | | | | | | | | s/SNGL/SINGLE/ s/SNGLE/SINGLE/ Fix abbreviation for P_STOPPED_* etc flags, in original code they were inconsistent and difficult to distinguish between them. Approved by: julian (mentor)
* In the kernel code, we have the tsleep() call with the PCATCH argument.davidxu2002-09-031-1/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PCATCH means 'if we get a signal, interrupt me!" and tsleep returns either EINTR or ERESTART depending on the circumstances. ERESTART is "special" because it causes the system call to fail, but right as it returns back to userland it tells the trap handler to move %eip back a bit so that userland will immediately re-run the syscall. This is a syscall restart. It only works for things like read() etc where nothing has changed yet. Note that *userland* is tricked into restarting the syscall by the kernel. The kernel doesn't actually do the restart. It is deadly for things like select, poll, nanosleep etc where it might cause the elapsed time to be reset and start again from scratch. So those syscalls do this to prevent userland rerunning the syscall: if (error == ERESTART) error = EINTR; Fake "signals" like SIGTSTP from ^Z etc do not normally invoke userland signal handlers. But, in -current, the PCATCH *is* being triggered and tsleep is returning ERESTART, and the syscall is aborted even though no userland signal handler was run. That is the fault here. We're triggering the PCATCH in cases that we shouldn't. ie: it is being triggered on *any* signal processing, rather than the case where the signal is posted to userland. --- Peter The work of psignal() is a patchwork of special case required by the process debugging and job-control facilities... --- Kirk McKusick "The design and impelementation of the 4.4BSD Operating system" Page 105 in STABLE source, when psignal is posting a STOP signal to sleeping process and the signal action of the process is SIG_DFL, system will directly change the process state from SSLEEP to SSTOP, and when SIGCONT is posted to the stopped process, if it finds that the process is still on sleep queue, the process state will be restored to SSLEEP, and won't wakeup the process. this commit mimics the behaviour in STABLE source tree. Reviewed by: Jon Mini, Tim Robbins, Peter Wemm Approved by: julian@freebsd.org (mentor)
* Split out a number of mostly VFS and signal related syscalls intoiedowse2002-09-011-29/+47
| | | | | | | | | | | | a kernel-internal kern_*() version and a wrapper that is called via the syscall vector table. For paths and structure pointers, the internal version either takes a uio_seg parameter or requires the caller to copyin() the data to kernel memory as appropiate. This will permit emulation layers to use these syscalls without having to copy out translated arguments to the stack gap. Discussed on: -arch Review/suggestions: bde, jhb, peter, marcel
* move the assert to cover more casesjulian2002-08-261-1/+1
|
* Don't re-lock the sched lock if we didn't unlock it.julian2002-08-231-1/+1
| | | | | | Original error by: David Xu <bsddiy@yahoo.com> Fix by: David Xu <bsddiy@yahoo.com> Completely failed to spot it: Julian Elischer <julian@freebsd.org>
* Revert some suspension/sleep/signal code from KSE-IIIjulian2002-08-211-43/+27
| | | | | | | | | We need to rethink a bit of this and it doesn't matter if we break the KSE test program for now as long as non-KSE programs act as expected. Submitted by: David Xu <bsddiy@yahoo.com> (this guy's just asking to get hit with a commit bit..)
* Do some work on keeping better track of stopped/continued state.julian2002-08-081-0/+2
| | | | | | | I'm not sure what happenned to the original setting of the P_CONTINUED flag. it appears to have been lost in the paper shuffling... Submitted by: David Xu <bsddiy@yahoo.com>
* Try harder to "set signal flags proprly [sic] for ast()". See rev.1.154.bde2002-08-061-0/+1
|
* Slight cleanup of some comments/whitespace.julian2002-08-011-6/+23
| | | | | | | | | | | | Make idle process state more consistant. Add an assert on thread state. Clean up idleproc/mi_switch() interaction. Use a local instead of referencing curthread 7 times in a row (I've been told curthread can be expensive on some architectures) Remove some commented out code. Add a little commented out code (completion coming soon) Reviewed by: jhb@freebsd.org
* Don't need to hold schedlock specifically for stop() ans it calls wakeup()julian2002-07-301-6/+1
| | | | | | that locks it anyhow. Reviewed by: jhb@freebsd.org
* revert some of the handling of STOP signals injulian2002-07-241-8/+0
| | | | | | | issignal(). Let thread_suspend_check() actually do the suspension at the user boundary. Submitted by: David Xu <bsddiy@yahoo.com>
* Rearrange the code so that it checks whether the file is somethingtruckman2002-07-101-9/+8
| | | | | | | valid to write a core dump to before doing the preparations to actually write to the file. Call VOP_GETATTR() before dropping the initial vnode lock.
* Try clean up some of the mess that resulted from layers and layersjulian2002-07-031-57/+31
| | | | | | of p4 merges from -current as things started getting different. Corroborated by: Similar patches just mailed by BDE.
* White space commit.julian2002-07-031-10/+10
| | | | | I'm working on this file but I wanted to make the whitespece commit separatly.
* Hold the sched lock across call to forward_signal() in tdsignal() togallatin2002-07-031-1/+4
| | | | | | keep SMP systems from panic'ing when ^C'ing an app suggested by julian
* Part 1 of KSE-IIIjulian2002-06-291-167/+219
| | | | | | | | | | | | | The ability to schedule multiple threads per process (one one cpu) by making ALL system calls optionally asynchronous. to come: ia64 and power-pc patches, patches for gdb, test program (in tools) Reviewed by: Almost everyone who counts (at various times, peter, jhb, matt, alfred, mini, bernd, and a cast of thousands) NOTE: this is still Beta code, and contains lots of debugging stuff. expect slight instability in signals..
* more caddr_t removal.alfred2002-06-291-4/+4
|
* - trapsignal() no longer needs to acquire Giant for ktrpsig().jhb2002-06-071-7/+5
| | | | - Catch up to new ktrace API.
* s/!SIGNOTEMPY/SIGISEMPTY/davidc2002-06-061-1/+1
| | | | Reviewed by: marcel, jhb, alfred
* Add POSIX.1-2001 WCONTINUED option for waitpid(2). A proc flagmike2002-06-011-0/+2
| | | | | | | | | | (P_CONTINUED) is set when a stopped process receives a SIGCONT and cleared after it has notified a parent process that has requested notification via waitpid(2) with WCONTINUED specified in its options operand. The status value can be checked with the new WIFCONTINUED() macro. Reviewed by: jake
* CURSIG() is not a macro so rename it cursig().julian2002-05-291-3/+3
| | | | Obtained from: KSE tree
* Change p_can{debug,see,sched,signal}()'s first argument to be a threadjhb2002-05-191-4/+3
| | | | | | | pointer instead of a proc pointer and require the process pointed to by the second argument to be locked. We now use the thread ucred reference for the credential checks in p_can*() as a result. p_canfoo() should now no longer need Giant.
* p_cansignal() returns an errno value; at some point, the check forrwatson2002-05-141-2/+2
| | | | | | | | | | inter-process signalling ceased to preserve and return that value, instead always returning EPERM. This meant that it was possible to "probe" the pid space for processes that were not otherwise visible. This change reverts that reversion. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* Remove trace_req().mini2002-05-091-14/+10
| | | | Reviewed by: alfred, jhb, peter
* expand_name fixes:alfred2002-05-081-38/+32
| | | | | | | | | | | | | | | .) don't use MAXPATHLEN + 1, fix logic to compensate. .) style(9) function parameters. .) fix line wrapping. .) remove duplicated error and string handling code. .) don't NUL terminate already NUL terminated string. .) all string length variables changed from int to size_t. .) constify variables. .) catch when corename would be truncated. .) cast pid_t and uid_t args for format string. .) add parens around return arguments. Help and suggestions from: bde
* M_ZERO the temp buffer in expand_name() otherwise if an error occursalfred2002-05-071-1/+1
| | | | | while logging we may pass a non NUL terminated string to log(9) for a %s format arg.
* Return the correct error code (ENOSYS, not EINVAL) from nosys(). Gettingbde2002-05-051-1/+1
| | | | | | | | | killed by SIGSYS for unimlemented syscalls is bad enough. Obtained from: Lite2 branch The Lite2 branch has some other interesting unmerged (?) bits in this file. They are well hidden among cosmetic regressions.
* - Reorder execve() so that it performs blocking operations before itjhb2002-05-021-2/+1
| | | | | | | | locks the process. - Defer other blocking operations such as vrele()'s until after we release locks. - execsigs() now requires the proc lock to be held when it is called rather than locking the process internally.
* Redo the sigio locking.alfred2002-05-011-4/+10
| | | | | | | | | | | Turn the sigio sx into a mutex. Sigio lock is really only needed to protect interrupts from dereferencing the sigio pointer in an object when the sigio itself is being destroyed. In order to do this in the most unintrusive manner change pgsigio's sigio * argument into a **, that way we can lock internally to the function.
* Avoid the user-visible effect of setting SA_NOCLDWAIT when theiedowse2002-04-271-3/+6
| | | | | | | SIGCHLD handler is SIG_IGN. This is a reimplementation of the problematic revision 1.131 of kern_exit.c. To avoid accessing process UPAGES, we set a new procsig flag when the SIGCHLD handler is SIG_IGN and use that instead.
* Lock proctree_lock instead of pgrpsess_lock.jhb2002-04-161-5/+5
|
* - Change killpg1()'s first argument to be a thread instead of a process sojhb2002-04-131-36/+22
| | | | | | | | | | | | | | | | we can use td_ucred. - In killpg1(), the proc lock is sufficient to check if p_stat is SZOMB or not. We don't need sched_lock. - Close some races in psignal(). In psignal() there is a big switch statement based on p_stat. All the different cases are assuming that the process (or thread) isn't going to change state out from under it. To ensure this is true, just lock sched_lock for the entire switch. We practically held it the entire time already anyways. This also simplifies the locking somewhat and actually results in fewer lock operations. - Allow signotify() to be called with the sched_lock held since psignal() now does that. - Use td_ucred in a couple of places.
OpenPOWER on IntegriCloud