Commit Graph

86 Commits

Author SHA1 Message Date
jdolecek 7d8eefdffc add void *p_emuldata into struct proc - this can be used to hold per-process
emulation-specific data
add process exit, exec and fork function hooks into struct emul:
* e_proc_fork() - called in fork1() after the new forked process is setup
* e_proc_exec() - called in sys_execve() after the executed process is setup
* e_proc_exit() - called in exit1() after all the other process cleanups are
  done, right before machine-dependant switch to new context; also called
  for "old" emulation from sys_execve() if emulation of executed program and
  the original process is different

This was discussed on tech-kern.
2000-11-07 12:41:52 +00:00
thorpej f759220f40 Define the MI parts of the "big kernel lock" perimeter. From
Bill Sommerfeld.
2000-08-22 17:28:28 +00:00
thorpej a91e7a7c6d Don't bother with a trampoline to start the pagedaemon and
reaper threads.
2000-08-12 22:41:53 +00:00
thorpej d66573f747 In reaper(), use ltsleep() instead of simple_unlock()/tsleep(). 2000-08-12 22:26:01 +00:00
thorpej cd32ace8bb ANSI'ify. 2000-08-01 04:57:28 +00:00
mrg 32aa199ccf remove include of <vm/vm.h> 2000-06-27 17:41:07 +00:00
mrg 2f159a1bac remove/move more mach vm header files:
<vm/pglist.h> -> <uvm/uvm_pglist.h>
	<vm/vm_inherit.h> -> <uvm/uvm_inherit.h>
	<vm/vm_kern.h> -> into <uvm/uvm_extern.h>
	<vm/vm_object.h> -> nothing
	<vm/vm_pager.h> -> into <uvm/uvm_pager.h>

also includes a bunch of <vm/vm_page.h> include removals (due to redudancy
with <vm/vm.h>), and a scattering of other similar headers.
2000-06-26 14:20:25 +00:00
sommerfeld 951310bf3f Remove a gratuitous use of curproc 2000-05-27 00:11:12 +00:00
thorpej 9fcc4f1a12 __predict_false() the test for init exiting. 2000-05-08 19:58:17 +00:00
thorpej f10e7dc65b Don't reset file size limit to infinity on exit. Instead, temporarily
raise the limit to infinity when writing out the accounting file.

From Artur Grabowski <art@stacken.kth.se>.
2000-05-08 19:06:36 +00:00
augustss 264f1d27c6 Get rid of register declarations. 2000-03-30 09:27:11 +00:00
thorpej b667a5a357 New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
  resource allocation.
- Insertion and removal of callouts is constant time, important as
  this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.
2000-03-23 06:30:07 +00:00
bouyer 52497e180a Remplace kern.shortcorename sysctl with a more flexible sheme,
core filename format, which allow to change the name of the core dump,
and to relocate it in a directory. Credits to Bill Sommerfeld for giving me
the idea :)
The default core filename format can be changed by options DEFCORENAME and/or
kern.defcorename
Create a new sysctl tree, proc, which holds per-process values (for now
the corename format, and resources limits). Process is designed by its pid
at the second level name. These values are inherited on fork, and the corename
fomat is reset to defcorename on suid/sgid exec.
Create a p_sugid() function, to take appropriate actions on suid/sgid
exec (for now set the P_SUGID flag and reset the per-proc corename).
Adjust dosetrlimit() to allow changing limits of one proc by another, with
credential controls.
1999-09-28 14:47:00 +00:00
thorpej 01a8cffe77 Add a read/write lock to the proclists and PID hash table. Use the
write lock when doing PID allocation, and during the process exit path.
Use a read lock every where else, including within schedcpu() (interrupt
context).  Note that holding the write lock implies blocking schedcpu()
from running (blocks softclock).

PID allocation is now MP-safe.

Note this actually fixes a bug on single processor systems that was probably
extremely difficult to tickle; it was possible that schedcpu() would run
off a bad pointer if the right clock interrupt happened to come in the
middle of a LIST_INSERT_HEAD() or LIST_REMOVE() to/from allproc.
1999-07-22 21:08:30 +00:00
thorpej 2715b812d1 Rework the process exit path, in preparation for making process exit
and PID allocation MP-safe.  A new process state is added: SDEAD.  This
state indicates that a process is dead, but not yet a zombie (has not
yet been processed by the process reaper).

SDEAD processes exist on both the zombproc list (via p_list) and deadproc
(via p_hash; the proc has been removed from the pidhash earlier in the exit
path).  When the reaper deals with a process, it changes the state to
SZOMB, so that wait4 can process it.

Add a P_ZOMBIE() macro, which treats a proc in SZOMB or SDEAD as a zombie,
and update various parts of the kernel to reflect the new state.
1999-07-22 18:13:36 +00:00
thorpej 32e1fd0d03 Move the call of cpu_wait() out of the wait4() functions, and into the
body of reaper(), right before the call to uvm_exit().  cpu_wait() must
be done before uvm_exit() because the resources it frees might be located
in the PCB.
1999-07-20 21:54:05 +00:00
thorpej c581bf97c5 A few things to make the Linux clone(2) emulation work a bit better:
- When the exit signal is specified to be 0, don't just assume they
  meant SIGCHLD.  In the Linux world, this appears to mean "don't deliver
  an exit signal at all".
- Simplify P_EXITSIG(); don't check against initproc here, just change
  the exit signal to SIGCHLD if reparenting to initproc.

A very simple clone(2) test program now works, and the MpegTV package
starts, but doesn't run properly yet (I believe there is a separate
bug which keeps it from working properly).
1999-07-15 23:18:41 +00:00
thorpej a6c810d72a Fix a (currently) harmless brian-o in last. 1999-05-13 17:28:30 +00:00
thorpej 5d97669cfe Allow an alternate exit signal (i.e. not SIGCHLD) to be delivered to the
parent, specified at fork time.  Specify a new flag to wait4(2), WALTSIG,
to wait for processes which use an alternate exit signal.

This is required for clone(2).
1999-05-13 00:59:03 +00:00
thorpej 2835fc6e46 Pull signal actions out of struct user, make them a separate proc
substructure, and allow them to be shared.

Required for clone(2).
1999-04-30 21:23:49 +00:00
thorpej 882d9195a3 Oops, forgot to commit this one. Free the cwdinfo on exit. 1999-04-30 20:54:04 +00:00
mrg d2397ac5f7 completely remove Mach VM support. all that is left is the all the
header files as UVM still uses (most of) these.
1999-03-24 05:50:49 +00:00
ross 6803dbddbb Replace the recent scheduler mods with calls to scheduler_{fork,wait}_hook(),
(inlined) so scheduler functionality can be kept in a single .h/.c set.
Also, the wait hook has changed the way it clips the scheduler history.
1999-02-23 02:57:18 +00:00
sommerfe 31a1ef68c7 Tweak to earlier fix to p_estcpu:
- no longer conditionalized
	- when traced, charge time to real parent, not debugger
	- make it clear for future rototillers that p_estcpu should be moved
	  to the "copy" region of struct proc.
1999-01-23 22:23:19 +00:00
ross d8d8301934 Fix the recently infamous "sucky performance" problem by charging wait(2)'ing
parents for children's p_estcpu. I think this problem has always been there.
It's particularly noticable with X because the server builds up non-trivial
CPU, and hence, non-trivial p_estcpu scheduler penalty. The repeatedly
forked children were always starting from scratch and receiving a scheduler
preference.
1999-01-23 08:25:36 +00:00
thorpej 04dc9a8878 Remove some code accidentally readded when Christos implement P_NOCLDWAIT. 1998-11-11 22:37:13 +00:00
tron fe8170d1b1 Defopt SYSVMSG, SYSVSEM and SYSVSHM. 1998-10-19 22:19:26 +00:00
christos eb1a214078 Add NOCLDWAIT (from FreeBSD) 1998-09-18 18:48:22 +00:00
christos 34c5a58bb4 Make copyrights consistent; fix weird/trailing spaces add missing (c) etc. 1998-09-12 17:20:02 +00:00
mycroft fb526e055c Substantial signal handling changes:
* Increase the size of sigset_t to accomodate 128 signals -- adding new
  versions of sys_setprocmask(), sys_sigaction(), sys_sigpending() and
  sys_sigsuspend() to handle the changed arguments.
* Abstract the guts of sys_sigaltstack(), sys_setprocmask(), sys_sigaction(),
  sys_sigpending() and sys_sigsuspend() into separate functions, and call them
  from all the emulations rather than hard-coding everything.  (Avoids uses
  the stackgap crap for these system calls.)
* Add a new flag (p_checksig) to indicate that a process may have signals
  pending and userret() needs to do the full (slow) check.
* Eliminate SAS_ALTSTACK; it's exactly the inverse of SS_DISABLE.
* Correct emulation bugs with restoring SS_ONSTACK.
* Make the signal mask in the sigcontext always use the emulated mask format.
* Store signals internally in sigaction structures, rather than maintaining a
  bunch of little sigsets for each SA_* bit.
* Keep track of where we put the signal trampoline, rather than figuring it out
  in *_sendsig().
* Issue a warning when a non-emulated sigaction bit is observed.
* Add missing emulated signals, and a native SIGPWR (currently not used).
* Implement the `not reset when caught' semantics for relevant signals.

Note: Only code touched by the i386 port has been modified.  Other ports and
emulations need to be updated.
1998-09-11 12:50:05 +00:00
thorpej 93ea1946f0 Implement a new kernel thread, the "reaper", which performs the task
of freeing the VM resources once a process has exited.  A valid thread
must do this work, as doing so may block in a multi-processor environment.
1998-09-08 23:57:58 +00:00
thorpej 8a1009afd9 Use the pool allocator and the "nointr" pool page allocator for rusage
structures.
1998-09-01 01:02:33 +00:00
thorpej 4dc0e91e12 Use the pool allocator and "nointr" pool page allocator for pcred and
plimit structures.
1998-08-31 23:20:16 +00:00
thorpej 0e28b643e9 Use a pool for proc structures. 1998-08-02 04:41:32 +00:00
perry 730baa7431 fix sizeofs so they comply with the KNF style guide. yes, it is pedantic. 1998-07-31 22:50:48 +00:00
thorpej 808867c7cf defopt KTRACE 1998-06-25 21:17:15 +00:00
christos 02cecf686a New fktrace syscall from Darren Reed [with fixes from me] 1998-05-02 18:33:19 +00:00
fvdl e5bc90f40c Merge with Lite2 + local changes 1998-03-01 02:20:01 +00:00
mrg d90485202c - add defopt's for UVM, UVMHIST and PMAP_NEW.
- remove unnecessary UVMHIST_DECL's.
1998-02-10 14:08:44 +00:00
mrg 1a8c7604f4 initial import of the new virtual memory system, UVM, into -current.
UVM was written by chuck cranor <chuck@maria.wustl.edu>, with some
minor portions derived from the old Mach code.  i provided some help
getting swap and paging working, and other bug fixes/ideas.  chuck
silvers <chuq@chuq.com> also provided some other fixes.

this is the rest of the MI portion changes.

this will be KNF'd shortly.  :-)
1998-02-05 07:59:28 +00:00
thorpej bb2d5987ff Don't call shmexit() if the vmspace ref count is not 1. Update for new
argument to shmexit().
1998-01-03 02:48:43 +00:00
mycroft 2b65c6c346 Delay turning off P_TRACED until the process is actually waited on. It can't
have any signals delivered while exiting, so this should be okay.  Change the
test for a traced process in wait4() to exclude a process that was started by
the debugger; in this case, only one SIGCHLD should be delivered.
1997-04-28 13:17:05 +00:00
mycroft 701f15db33 Reinstate P_FSTRACE, with different semantics:
* Never send a SIGCHLD to the parent if P_FSTRACE is set.
* Do not permit mixing ptrace(2) and procfs; only permit using the one that
  was attached.
1997-04-28 04:49:27 +00:00
mycroft 43a0dc8b74 Remove remnants of P_FSTRACE, which is no longer used. 1997-04-28 02:51:41 +00:00
mycroft 1cf91041df Nuke the old COMPAT_09 truncation of UIDs, GIDs, process and process group IDs. 1997-04-23 18:59:53 +00:00
mikel e707982f35 check options argument to wait{3,4,pid}(); from Klaus Klein in PR 3182. 1997-02-07 05:33:07 +00:00
perry 8a0600b163 removed #ifdef tahoe 1996-10-17 16:31:54 +00:00
christos 4ef330b934 remove include of <sys/cpu.h> 1996-04-22 01:38:12 +00:00
christos 09afd77655 More proto fixes 1996-02-09 18:59:18 +00:00
mycroft bf6bf23e7b If parent is in ppwait, wake it up early to prevent deadlock. 1996-02-09 01:19:21 +00:00