summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_proc.c
Commit message (Collapse)AuthorAgeFilesLines
* Add sysctls to allow showing threads for pgrp, tty, uid, ruid,deischen2004-02-221-7/+31
| | | | and pid.
* - Update the sched api. sched_{add,rem,clock,pctcpu} now all accept a tdjeff2003-10-161-6/+3
| | | | argument rather than a kse.
* The KERN_PROC_PROC sysctl took 4 args in 5.0-REL and 5.1-REL. We need topeter2003-10-151-1/+4
| | | | | accept this for a bit longer. Requiring the new order of 3 args only was not very helpful.
* Remove support for the unused 4th component of the KERN_PROC_PROC sysctl.tjr2003-10-061-6/+0
|
* Allow the KERN_PROC_PROC sysctl to be used without the useless 4thtjr2003-09-191-6/+18
| | | | | name component, for consistency with KERN_PROC_ALL. Support for the 4-argument form will be removed some time before 5.2-R.
* kse.h is not needed for these files.davidxu2003-08-051-1/+0
|
* Correct six return statements which returned zero instead ofrobert2003-07-171-9/+10
| | | | | | | | | | an appropriate error number after a failure condition. In particular, three of the changed statements return ESRCH for a failed pfind(), and in also three places a non-zero return from p_cansee() will be passed back, Also noticed by: rwatson
* Make the system call vector name of a process accessible to userrobert2003-07-121-0/+29
| | | | | land applications by introducing the KERN_PROC_SV_NAME sysctl node, which is searchable by PID.
* Drop the proc lock around SYSCTL_OUT in the no-threads case.scottl2003-06-171-0/+2
| | | | Submitted by: truckman
* Move the *_new_altkstack() and *_dispose_altkstack() functions out of thealc2003-06-141-1/+1
| | | | | various pmap implementations into the machine-independent vm. They were all identical.
* Add support to sysctl_kern_proc to return all threads in a proc, not just thescottl2003-06-121-56/+90
| | | | | | first one. The old behaviour can be switched by specifying KERN_PROC_PROC. Submitted by: julian, tweaks and added functionality by myself
* Use __FBSDID().obrien2003-06-111-1/+3
|
* - Merge struct procsig with struct sigacts.jhb2003-05-131-3/+7
| | | | | | | | | | | | | | | | | - Move struct sigacts out of the u-area and malloc() it using the M_SUBPROC malloc bucket. - Add a small sigacts_*() API for managing sigacts structures: sigacts_alloc(), sigacts_free(), sigacts_copy(), sigacts_share(), and sigacts_shared(). - Remove the p_sigignore, p_sigacts, and p_sigcatch macros. - Add a mutex to struct sigacts that protects all the members of the struct. - Add sigacts locking. - Remove Giant from nosys(), kill(), killpg(), and kern_sigaction() now that sigacts is locked. - Several in-kernel functions such as psignal(), tdsignal(), trapsignal(), and thread_stopped() are now MP safe. Reviewed by: arch@ Approved by: re (rwatson)
* Initialize and destroy the struct proc mutex in the proc zone's init andjhb2003-05-011-0/+3
| | | | | | | fini routines instead of in fork() and wait(). This has the nice side benefit that the proc lock of any process on the allproc list is always valid and sched_lock doesn't have to be used to test against PRS_NEW anymore.
* Instead of recording the Unix time in a process when it starts, record thedes2003-05-011-2/+1
| | | | | | | uptime. Where necessary, convert it back to Unix time by adding boottime to it. This fixes a potential problem in the accounting code, which would compute the elapsed time incorrectly if the Unix time was stepped during the lifetime of the process.
* Include altkstack pages in the RSS regardless of whether the processtjr2003-04-251-8/+6
| | | | is swapped out. Pointed out by jhb.
* It seems that 1 was not a magic value as I thought, but a coincidence.des2003-04-241-2/+2
| | | | | | | | Instead of applying the adjustment to processes with a start time of 1, apply it to all processes with a start time of less than 3600. None of this would be necessary if the start times were recorded in ticks instead of seconds and microseconds.
* Do a better job of calculating the RSS for swapped-out processes:tjr2003-04-241-3/+9
| | | | | | | | don't include the kernel stacks of swapped-out threads in the page count, but do include the alternate kernel stack. jhb provided some helpful comments on this. PR: 49102
* When filling out a kinfo_proc structure, if we come across a processdes2003-04-241-0/+2
| | | | | | whose p_stats->p_start has the magic value 1, replace it with boottime. Some users were apparently confused by the fact that ps(1) reported a start time in early 1970 for system processes.
* - Add a static function pgadjustjobc() to adjust the job control count forjhb2003-04-181-36/+42
| | | | | | | | | a process group. - Call pgadjustjobc() twice in fixjobc() to avoid code duplication and improve readability. - Use the proc lock to protect P_SHOULDSTOP() instead of sched_lock. - Check to see if a process is PRS_NEW with sched_lock before trying to lock its proc lock since the lock may not be constructed yet.
* Move the _oncpu entry from the KSE to the thread.julian2003-04-101-1/+1
| | | | | The entry in the KSE still exists but it's purpose will change a bit when we add the ability to lock a KSE to a cpu.
* - Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread withjeff2003-03-311-3/+6
| | | | | | | 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.
* - Cache a reference to the credential of the thread that starts a ktrace injhb2003-03-131-1/+1
| | | | | | | | | | | struct proc as p_tracecred alongside the current cache of the vnode in p_tracep. This credential is then used for all later ktrace operations on this file rather than using the credential of the current thread at the time of each ktrace event. - Now that we have multiple ktrace-related items in struct proc that are pointers, rename p_tracep to p_tracevp to make it less ambiguous. Requested by: rwatson (1)
* - Various little style fixes.jhb2003-03-121-8/+5
| | | | | | | | | - If SYSCTL_OUT() fails in sysctl_kern_proc_args(), return the error instead of ignoring it if we have new arguments for the process. - If the new arguments for a process are too long, return ENOMEM instead of returning success but not doing the actual copy. Submitted by: bde
* - Avoid dropping the proc lock around a simple permissions check and justjhb2003-03-121-18/+16
| | | | | | | | | hold hold it across the check to avoid extra lock operations in the common case. - Copy in the new args to a temporary pargs structure before we drop the reference to the old one. Thus, if the copyin() fails, the process arguments are unchanged rather than being deleted. Also, p_args is no longer NULL during the sysctl operation.
* Change the process flags P_KSES to be P_THREADED.julian2003-02-271-2/+2
| | | | This is just a cosmetic change but I've been meaning to do it for about a year.
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-1/+1
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Remove unnecessary lock assertion.hsu2003-01-041-15/+1
|
* Fix typos, mostly s/ an / a / where appropriate and a few s/an/and/schweikh2002-12-301-1/+1
| | | | Add FreeBSD Id tag where missing.
* - Add the new sched_pctcpu() function to the sched_* api.jeff2002-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
* - Implement a mechanism for allowing schedulers to place scheduler dependantjeff2002-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
* Move thread related code from kern_proc.c to kern_thread.c.julian2002-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
* detect idle kse correctly.davidxu2002-10-221-1/+1
|
* Add an actual implementation of kse_wakeup()julian2002-10-201-1/+41
| | | | Submitted by: Davidxu
* Use strlcpy() instead of strncpy() to copy NUL terminated stringsrobert2002-10-171-8/+8
| | | | for safety and consistency.
* - Add a new global mutex 'ppeers_lock' to protect the p_peers list ofjhb2002-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)
* Round out the facilty for a 'bound' thread to loan out its KSEjulian2002-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.
* Rename the mutex thread and process states to use a more generic 'LOCK'jhb2002-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.
* Let kse_wakeup() take a KSE mailbox pointer argument.archie2002-10-021-0/+3
| | | | Reviewed by: julian
* Some kernel threads try to do significant work, and the default KSTACK_PAGESscottl2002-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
* Back our kernel support for reliable signal queues.jmallett2002-10-011-3/+2
| | | | Requested by: rwatson, phk, and many others
* First half of implementation of ksiginfo, signal queues, and such. Thisjmallett2002-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]
* Implement basic KSE loaning. This stops a hread that is blocked in BOUND modejulian2002-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
* Rewrite the kse_create() function to better aproach the semantics wejulian2002-09-281-56/+71
| | | | have specified in the design.
* Make the following name changes to KSE related functions, etc., to betterarchie2002-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
* oops don't do dthe copy range in a new KSE. There isn't one any more.julian2002-09-231-0/+2
|
* Add code to create > 1 KSe per process.julian2002-09-231-16/+39
| | | | | | (support code not yet complete) Submitted by: davidxu
* Add kernel support needed for the KSE-aware libpthread: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
* Allocate KSEs and KSEGRPs separatly and remove them from the proc structure.julian2002-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.
OpenPOWER on IntegriCloud