summaryrefslogtreecommitdiff
path: root/sys/kern/kern_proc.c
Commit message (Collapse)AuthorAgeFilesLines
* Change the process flags P_KSES to be P_THREADED.Julian Elischer2003-02-271-2/+2
| | | | | | | This is just a cosmetic change but I've been meaning to do it for about a year. Notes: svn path=/head/; revision=111585
* Back out M_* changes, per decision of the TRB.Warner Losh2003-02-191-1/+1
| | | | | | | Approved by: trb Notes: svn path=/head/; revision=111119
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.Alfred Perlstein2003-01-211-1/+1
| | | | | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT. Notes: svn path=/head/; revision=109623
* Remove unnecessary lock assertion.Jeffrey Hsu2003-01-041-15/+1
| | | | Notes: svn path=/head/; revision=108660
* Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/Jens Schweikhardt2002-12-301-1/+1
| | | | | | | Add FreeBSD Id tag where missing. Notes: svn path=/head/; revision=108470
* - Add the new sched_pctcpu() function to the sched_* api.Jeff Roberson2002-11-211-1/+1
| | | | | | | | | | | - Provide a routine in sched_4bsd to add this functionality. - Use sched_pctcpu() in kern_proc, which is the one place outside of sched_4bsd where the old pctcpu value was accessed directly. Approved by: re Notes: svn path=/head/; revision=107137
* - Implement a mechanism for allowing schedulers to place scheduler dependantJeff Roberson2002-11-211-9/+3
| | | | | | | | | | | | data in the scheduler independant structures (proc, ksegrp, kse, thread). - Implement unused stubs for this mechanism in sched_4bsd. Approved by: re Reviewed by: luigi, trb Tested on: x86, alpha Notes: svn path=/head/; revision=107126
* Move thread related code from kern_proc.c to kern_thread.c.Julian Elischer2002-10-241-258/+0
| | | | | | | | | | | | | Add code to free KSEs and KSEGRPs on exit. Sort KSE prototypes in proc.h. Add the missing kse_exit() syscall. ksetest now does not leak KSEs and KSEGRPS. Submitted by: (parts) davidxu Notes: svn path=/head/; revision=105854
* detect idle kse correctly.David Xu2002-10-221-1/+1
| | | | Notes: svn path=/head/; revision=105674
* Add an actual implementation of kse_wakeup()Julian Elischer2002-10-201-1/+41
| | | | | | | Submitted by: Davidxu Notes: svn path=/head/; revision=105559
* Use strlcpy() instead of strncpy() to copy NUL terminated stringsRobert Drehmel2002-10-171-8/+8
| | | | | | | for safety and consistency. Notes: svn path=/head/; revision=105354
* - Add a new global mutex 'ppeers_lock' to protect the p_peers list ofJohn Baldwin2002-10-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | processes forked with RFTHREAD. - Use a goto to a label for common code when exiting from fork1() in case of an error. - Move the RFTHREAD linkage setup code later in fork since the ppeers_lock cannot be locked while holding a proc lock. Handle the race of a task leader exiting and killing its peers while a peer is forking a new child. In that case, go ahead and let the peer process proceed normally as the parent is about to kill it. However, the task leader may have already gone to sleep to wait for the peers to die, so the new child process may not receive a SIGKILL from the task leader. Rather than try to destruct the new child process, just go ahead and send it a SIGKILL directly and add it to the p_peers list. This ensures that the task leader will wait until both the peer process doing the fork() and the new child process have received their KILL signals and exited. Discussed with: truckman (earlier versions) Notes: svn path=/head/; revision=105141
* Round out the facilty for a 'bound' thread to loan out its KSEJulian Elischer2002-10-091-19/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | in specific situations. The owner thread must be blocked, and the borrower can not proceed back to user space with the borrowed KSE. The borrower will return the KSE on the next context switch where teh owner wants it back. This removes a lot of possible race conditions and deadlocks. It is consceivable that the borrower should inherit the priority of the owner too. that's another discussion and would be simple to do. Also, as part of this, the "preallocatd spare thread" is attached to the thread doing a syscall rather than the KSE. This removes the need to lock the scheduler when we want to access it, as it's now "at hand". DDB now shows a lot mor info for threaded proceses though it may need some optimisation to squeeze it all back into 80 chars again. (possible JKH project) Upcalls are now "bound" threads, but "KSE Lending" now means that other completing syscalls can be completed using that KSE before the upcall finally makes it back to the UTS. (getting threads OUT OF THE KERNEL is one of the highest priorities in the KSE system.) The upcall when it happens will present all the completed syscalls to the KSE for selection. Notes: svn path=/head/; revision=104695
* Rename the mutex thread and process states to use a more generic 'LOCK'John Baldwin2002-10-021-6/+6
| | | | | | | | | | | | name instead. (e.g., SLOCK instead of SMTX, TD_ON_LOCK() instead of TD_ON_MUTEX()) Eventually a turnstile abstraction will be added that will be shared with mutexes and other types of locks. SLOCK/TDI_LOCK will be used internally by the turnstile code and will not be specific to mutexes. Making the change now ensures that turnstiles can be dropped in at a later date without affecting the ABI of userland applications. Notes: svn path=/head/; revision=104387
* Let kse_wakeup() take a KSE mailbox pointer argument.Archie Cobbs2002-10-021-0/+3
| | | | | | | Reviewed by: julian Notes: svn path=/head/; revision=104379
* Some kernel threads try to do significant work, and the default KSTACK_PAGESScott Long2002-10-021-0/+9
| | | | | | | | | | | | | | | | doesn't give them enough stack to do much before blowing away the pcb. This adds MI and MD code to allow the allocation of an alternate kstack who's size can be speficied when calling kthread_create. Passing the value 0 prevents the alternate kstack from being created. Note that the ia64 MD code is missing for now, and PowerPC was only partially written due to the pmap.c being incomplete there. Though this patch does not modify anything to make use of the alternate kstack, acpi and usb are good candidates. Reviewed by: jake, peter, jhb Notes: svn path=/head/; revision=104354
* Back our kernel support for reliable signal queues.Juli Mallett2002-10-011-3/+2
| | | | | | | Requested by: rwatson, phk, and many others Notes: svn path=/head/; revision=104306
* First half of implementation of ksiginfo, signal queues, and such. ThisJuli Mallett2002-09-301-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | 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] Notes: svn path=/head/; revision=104233
* Implement basic KSE loaning. This stops a hread that is blocked in BOUND modeJulian Elischer2002-09-291-1/+3
| | | | | | | | | | | | from stopping another thread from completing a syscall, and this allows it to release its resources etc. Probably more related commits to follow (at least one I know of) Initial concept by: julian, dillon Submitted by: davidxu Notes: svn path=/head/; revision=104157
* Rewrite the kse_create() function to better aproach the semantics weJulian Elischer2002-09-281-56/+71
| | | | | | | have specified in the design. Notes: svn path=/head/; revision=104082
* Make the following name changes to KSE related functions, etc., to betterArchie Cobbs2002-09-251-9/+10
| | | | | | | | | | | | | | | | | | represent their purpose and minimize namespace conflicts: kse_fn_t -> kse_func_t struct thread_mailbox -> struct kse_thr_mailbox thread_interrupt() -> kse_thr_interrupt() kse_yield() -> kse_release() kse_new() -> kse_create() Add missing declaration of kse_thr_interrupt() to <sys/kse.h>. Regenerate the various generated syscall files. Minor style fixes. Reviewed by: julian Notes: svn path=/head/; revision=103972
* oops don't do dthe copy range in a new KSE. There isn't one any more.Julian Elischer2002-09-231-0/+2
| | | | Notes: svn path=/head/; revision=103858
* Add code to create > 1 KSe per process.Julian Elischer2002-09-231-16/+39
| | | | | | | | | (support code not yet complete) Submitted by: davidxu Notes: svn path=/head/; revision=103835
* Add kernel support needed for the KSE-aware libpthread:Jonathan Mini2002-09-161-5/+22
| | | | | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=103410
* Allocate KSEs and KSEGRPs separatly and remove them from the proc structure.Julian Elischer2002-09-151-40/+44
| | | | | | | | | | | | 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. Notes: svn path=/head/; revision=103367
* Completely redo thread states.Julian Elischer2002-09-111-5/+5
| | | | | | | Reviewed by: davidxu@freebsd.org Notes: svn path=/head/; revision=103216
* Make UAREA_PAGES and KSTACK_PAGES visible to userland via sysctl, likePeter Wemm2002-09-071-0/+6
| | | | | | | | | | | PS_STRINGS and USRSTACK is. This is necessary in order to decode a.out core dumps. kern_proc.c was already referring to both of these values but was missing the #include "opt_kstack_pages.h". Make the sysctl variables visible so that certain kld modules can see how their parent kernel was configured. Notes: svn path=/head/; revision=103083
* Minor spelling tweak: assume "his" is actually "This".Robert Watson2002-09-061-1/+1
| | | | Notes: svn path=/head/; revision=103014
* Use UMA as a complex object allocator.Julian Elischer2002-09-061-17/+31
| | | | | | | | | | | | | | | | | | The process allocator now caches and hands out complete process structures *including substructures* . i.e. it get's the process structure with the first thread (and soon KSE) already allocated and attached, all in one hit. For the average non threaded program (non KSE that is) the allocated thread and its stack remain attached to the process, even when the process is unused and in the process cache. This saves having to allocate and attach it later, effectively bringing us (hopefully) close to the efficiency of pre-KSE systems where these were a single structure. Reviewed by: davidxu@freebsd.org, peter@freebsd.org Notes: svn path=/head/; revision=103002
* Fix typos; each file has at least one s/seperat/separat/Jens Schweikhardt2002-08-111-5/+5
| | | | | | | | | | | | | (I skipped those in contrib/, gnu/ and crypto/) While I was at it, fixed a lot more found by ispell that I could identify with certainty to be errors. All of these were in comments or text, not in actual code. Suggested by: bde MFC after: 3 days Notes: svn path=/head/; revision=101677
* Wire the sysctl output buffer before grabbing any locks to preventDon Lewis2002-07-281-0/+1
| | | | | | | | | | SYSCTL_OUT() from blocking while locks are held. This should only be done when it would be inconvenient to make a temporary copy of the data and defer calling SYSCTL_OUT() until after the locks are released. Notes: svn path=/head/; revision=100831
* Thinking about it I came to the conclusion that the KSE states were incorrectlyJulian Elischer2002-07-141-2/+0
| | | | | | | | | | | | | | | | | formulated. The correct states should be: IDLE: On the idle KSE list for that KSEG RUNQ: Linked onto the system run queue. THREAD: Attached to a thread and slaved to whatever state the thread is in. This means that most places where we were adjusting kse state can go away as it is just moving around because the thread is.. The only places we need to adjust the KSE state is in transition to and from the idle and run queues. Reviewed by: jhb@freebsd.org Notes: svn path=/head/; revision=99942
* Collect all the (now equivalent) pmap_new_proc/pmap_dispose_proc/Peter Wemm2002-07-071-2/+103
| | | | | | | | | | | | | | | | pmap_swapin_proc/pmap_swapout_proc functions from the MD pmap code and use a single equivalent MI version. There are other cleanups needed still. While here, use the UMA zone hooks to keep a cache of preinitialized proc structures handy, just like the thread system does. This eliminates one dependency on 'struct proc' being persistent even after being freed. There are some comments about things that can be factored out into ctor/dtor functions if it is worth it. For now they are mostly just doing statistics to get a feel of how it is working. Notes: svn path=/head/; revision=99559
* If the process is a zombie, then you must not try dereference the threadJulian Elischer2002-06-301-53/+55
| | | | | | | | because there isn't one. Of course this code only possibly works for single threaded processes anyhow.. Notes: svn path=/head/; revision=99124
* Part 1 of KSE-IIIJulian Elischer2002-06-291-73/+144
| | | | | | | | | | | | | | | | 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.. Notes: svn path=/head/; revision=99072
* Always drop the p_args reference we held for copyout, even if we're aboutJonathan Mini2002-06-221-3/+2
| | | | | | | | | | to change it. This fixes a leak triggered by setproctitle(3). Approved by: alfred Noticed by: Peter Jeremy <peter.jeremy@alcatel.com.au> Notes: svn path=/head/; revision=98609
* Properly lock accesses to p_tracep and p_traceflag. Also make a fewJohn Baldwin2002-06-071-2/+12
| | | | | | | ktrace-only things #ifdef KTRACE that were not before. Notes: svn path=/head/; revision=97997
* Change p_can{debug,see,sched,signal}()'s first argument to be a threadJohn Baldwin2002-05-191-3/+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. Notes: svn path=/head/; revision=96886
* Make funsetown() take a 'struct sigio **' so that the locking canAlfred Perlstein2002-05-061-4/+1
| | | | | | | | | | | | | | | | | | | be done internally. Ensure that no one can fsetown() to a dying process/pgrp. We need to check the process for P_WEXIT to see if it's exiting. Process groups are already safe because there is no such thing as a pgrp zombie, therefore the proctree lock completely protects the pgrp from having sigio structures associated with it after it runs funsetownlst. Add sigio lock to witness list under proctree and allproc, but over proc and pgrp. Seigo Tanimura helped with this. Notes: svn path=/head/; revision=96122
* As malloc(9) and free(9) are now Giant-free, remove the Giant lockSeigo Tanimura2002-05-031-5/+1
| | | | | | | across malloc(9) and free(9) of a pgrp or a session. Notes: svn path=/head/; revision=95973
* Fix the lock order reversal between the sigio lock and a process/pgrp lock inSeigo Tanimura2002-05-031-0/+2
| | | | | | | funsetownlst() by locking the sigio lock across funsetownlst(). Notes: svn path=/head/; revision=95969
* Free(9) should be Giant-free.Seigo Tanimura2002-04-241-1/+1
| | | | | | | Suggested by: jhb Notes: svn path=/head/; revision=95352
* Push down Giant for setpgid(), setsid() and aio_daemon(). Giant protects onlySeigo Tanimura2002-04-201-1/+5
| | | | | | | malloc(9) and free(9). Notes: svn path=/head/; revision=95123
* - Merge the pgrpsess_lock and proctree_lock sx locks into one proctree_lockJohn Baldwin2002-04-161-14/+10
| | | | | | | | | | | | | | | sx lock. Trying to get the lock order between these locks was getting too complicated as the locking in wait1() was being fixed. - leavepgrp() now requires an exclusive lock of proctree_lock to be held when it is called. - fixjobc() no longer gets a shared lock of proctree_lock now that it requires an xlock be held by the caller. - Locking notes in sys/proc.h are adjusted to note that everything that used to be protected by the pgrpsess_lock is now protected by the proctree_lock. Notes: svn path=/head/; revision=94857
* - Change fill_kinfo_proc() to require that the process is locked when itJohn Baldwin2002-04-091-14/+20
| | | | | | | | | | | | | | | | | is called. - Change sysctl_out_proc() to require that the process is locked when it is called and to drop the lock before it returns. If this proves too complex we can change sysctl_out_proc() to simply acquire the lock at the very end and have the calling code drop the lock right after it returns. - Lock the process we are going to export before the p_cansee() in the loop in sysctl_kern_proc() and hold the lock until we call sysctl_out_proc(). - Don't call p_cansee() on the process about to be exported twice in the aforementioned loop. Notes: svn path=/head/; revision=94307
* Use CTASSERT rather than a runtime check to detect kinfo_proc size changes.Jake Burkholder2002-04-061-16/+2
| | | | | | | Remove the ugly yuck code to busy wait for 20 seconds. Notes: svn path=/head/; revision=93942
* Change callers of mtx_init() to pass in an appropriate lock type name. InJohn Baldwin2002-04-041-3/+3
| | | | | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64 Notes: svn path=/head/; revision=93818
* Stage-2 commit of the critical*() code. This re-inlines cpu_critical_enter()Matthew Dillon2002-04-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | and cpu_critical_exit() and moves associated critical prototypes into their own header file, <arch>/<arch>/critical.h, which is only included by the three MI source files that need it. Backout and re-apply improperly comitted syntactical cleanups made to files that were still under active development. Backout improperly comitted program structure changes that moved localized declarations to the top of two procedures. Partially re-apply one of the program structure changes to move 'mask' into an intermediate block rather then in three separate sub-blocks to make the code more readable. Re-integrate bug fixes that Jake made to the sparc64 code. Note: In general, developers should not gratuitously move declarations out of sub-blocks. They are where they are for reasons of structure, grouping, readability, compiler-localizability, and to avoid developer-introduced bugs similar to several found in recent years in the VFS and VM code. Reviewed by: jake Notes: svn path=/head/; revision=93607
* Close some holes with p->p_args by NULL'ing out the p->p_args pointerAlfred Perlstein2002-03-311-3/+10
| | | | | | | | | | while holding the proc lock, and by holding the pargs structure when accessing it from outside of the owner. Submitted by: Jonathan Mini <mini@haikugeek.com> Notes: svn path=/head/; revision=93471
* To remove nested include of sys/lock.h and sys/mutex.h from sys/proc.hAlfred Perlstein2002-03-281-0/+44
| | | | | | | | | make the pargs_* functions into non-inlines in kern/kern_proc.c. Requested by: bde Notes: svn path=/head/; revision=93348