summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sig.c
Commit message (Collapse)AuthorAgeFilesLines
* - p will be unused in cursig() if INVARIANTS is not defined. Access itjeff2003-04-011-3/+1
| | | | | | through td->td_proc to avoid the unused variable. Spotted by: Maxim Konovalov <maxim@macomnet.ru>
* - Define sigwait, sigtimedwait, and sigwaitinfo in terms ofjeff2003-03-311-1/+173
| | | | | | kern_sigtimedwait() which is capable of supporting all of their semantics. - These should be POSIX compliant but more careful review is needed before we announce this.
* - Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread withjeff2003-03-311-111/+209
| | | | | | | a follow on commit to kern_sig.c - signotify() now operates on a thread since unmasked pending signals are stored in the thread. - PS_NEEDSIGCHK moves to TDF_NEEDSIGCHK.
* - Mark signals which may be delivered to any thread in the process withjeff2003-03-311-31/+32
| | | | | SA_PROC. Signals without this flag should be directed to a particular thread if this is possible.
* - Change trapsignal() to accept a thread and not a proc.jeff2003-03-311-6/+6
| | | | | | | - Change all consumers to pass in a thread. Right now this does not cause any functional changes but it will be important later when signals can be delivered to specific threads.
* Fix threaded process job control bug. SMP tested.davidxu2003-03-111-27/+33
| | | | Reviewed by: julian
* Hold the proc lock while accessing p_procsig in trapsignal().tjr2003-03-091-1/+2
|
* Replace calls to WITNESS_SLEEP() and witness_list() with equivalent callsjhb2003-03-041-1/+2
| | | | to WITNESS_WARN().
* Change the process flags P_KSES to be P_THREADED.julian2003-02-271-1/+1
| | | | This is just a cosmetic change but I've been meaning to do it for about a year.
* Fix a bug when handling SIGCONT.davidxu2003-02-261-7/+0
| | | | Reported By: Mike Makonnen <mtm@identd.net>
* - Add a new function, thread_signal_add(), that is called from postsig tojeff2003-02-171-3/+4
| | | | | | | | add a signal to a mailbox's pending set. - Add a new function, thread_signal_upcall(), this causes the current thread to upcall so that we can deliver pending signals. Reviewed by: mini
* Move a bunch of flags from the KSE to the thread.julian2003-02-171-3/+3
| | | | | | | | I was in two minds as to where to put them in the first case.. I should have listenned to the other mind. Submitted by: parts by davidxu@ Reviewed by: jeff@ mini@
* - Split the struct kse into struct upcall and struct kse. struct kse willjeff2003-02-171-6/+0
| | | | | | | soon be visible only to schedulers. This greatly simplifies much the KSE code. Submitted by: davidxu
* Acquire Giant around calls to kern_sigaction() in sigaction(),tjr2003-02-151-17/+9
| | | | | | | freebsd4_sigaction() and osigaction() instead of around the whole body of those functions. They now no longer hold Giant around calls to copyin() and copyout(), and it is slightly more obvious what Giant is protecting.
* osigpending() no longer needs Giant, for the same reason sigpending()tjr2003-02-151-3/+0
| | | | does not.
* All uses of p_siglist are protected by the proc lock now, so there'stjr2003-02-151-6/+1
| | | | no need to acquire Giant in sigpending() anymore.
* 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..
OpenPOWER on IntegriCloud