summaryrefslogtreecommitdiff
path: root/sys/kern/kern_fork.c
AgeCommit message (Collapse)Author
2007-03-15Since p_flag is often manipulated in interrupts and without biglockArtur Grabowski
it's a good idea to use atomic.h operations on it. This mechanic change updates all bit operations on p_flag to atomic_{set,clear}bits_int. Only exception is that P_OWEUPC is set by MI code before calling need_proftick and it's automatically cleared by ADDUPC. There's no reason for MD handling of that flag since everyone handles it the same way. kettenis@ ok
2007-01-17reintroduce rev 1.83 -- put the new process on the proc listsMichael Shalayeff
later when more of it's resources have been allocated and thus kill(2)ing such a process has more predictable results. now w/ a couple of kettenis remarks; kettenis@ miod@ ok
2006-11-29Kernel stack can be swapped. This means that stuff that's on the stackMiod Vallat
should never be referenced outside the context of the process to which this stack belongs unless we do the PHOLD/PRELE dance. Loads of code doesn't follow the rules here. Instead of trying to track down all offenders and fix this hairy situation, it makes much more sense to not swap kernel stacks. From art@, tested by many some time ago.
2006-04-30Backout last commit, it makes us crash when a ptraced program forks.Mark Kettenis
2006-03-27do not rush putting embrionic process on child/thread/sibling lists and set ↵Michael Shalayeff
timeouts earlier as we can sleep later and get signals and exit and cause all kinds of hell; pedro@ ok
2006-02-20Compile out more rthreads stuff unless option RTHREADS;Miod Vallat
discussed with a few, ok tedu@
2005-12-22fix memory leak conditions in thrsleep and significantly simplifyTed Unangst
2005-12-04forgot to set P_THREAD for threaded processesTed Unangst
2005-12-03kernel support for threaded processes (rthreads).Ted Unangst
uses rfork(RFTHREAD) to create threads, which are presently processes that are a little more tightly bound together. several new syscalls added to facilitate a userland thread library. all conditional on RTHREADS, currently disabled. ok deraadt
2005-11-02Avoid a theoretical race condition.Aaron Campbell
In fork1(), setup the p_{prof,virt}_to timeouts _before_ putting the process on the runqueue. Since SCHED_UNLOCK() can cause pre-emption, it is possible (with the old code) for the newly created process to run and become curproc before the timeouts were set. If itimers are set early, and you're unlucky, hardclock() might fire at this time and attempt timeout_add() on the unset timeouts, leading to "panic: timeout_add: not initialized". deraadt@, miod@ ok
2005-09-14ptrace(2) following fork(2)Mark Kettenis
ok miod@
2005-05-29sched work by niklas and art backed out; causes panicsTheo de Raadt
2005-05-25This patch is mortly art's work and was done *a year* ago. Art wants to thankNiklas Hallqvist
everyone for the prompt review and ok of this work ;-) Yeah, that includes me too, or maybe especially me. I am sorry. Change the sched_lock to a mutex. This fixes, among other things, the infamous "telnet localhost &" problem. The real bug in that case was that the sched_lock which is by design a non-recursive lock, was recursively acquired, and not enough releases made us hold the lock in the idle loop, blocking scheduling on the other processors. Some of the other processors would hold the biglock though, which made it impossible for cpu 0 to enter the kernel... A nice deadlock. Let me just say debugging this for days just to realize that it was all fixed in an old diff noone ever ok'd was somewhat of an anti-climax. This diff also changes splsched to be correct for all our architectures.
2005-02-24fix pr4036, don't set p2->p_cpu to nullTed Unangst
ok deraadt miod markus
2004-11-23Create the init process earlier, before the root filesystem is mounted,Miod Vallat
and have it stall on a semaphore. This allows all kthread creations which could have been requested during autoconf to be processed before root is mounted as well. This causes umass devices attached to any usb with flags 1 (such as on macppc) to configure properly instead of panicing the kernel at mountroot time. From NetBSD; tested by various.
2004-08-06provide md USPACE_ALIGN zero on all but mips; deradat@ pefo@ okMichael Shalayeff
2004-08-04hardclock detects if ITIMER_VIRTUAL and ITIMER_PROF have expired andArtur Grabowski
sends SIGVTALRM and SIGPROF to the process if they had. There is a big problem with calling psignal from hardclock on MULTIPROCESSOR machines though. It means we need to protect all signal state in the process with a lock because hardclock doesn't obtain KERNEL_LOCK. Trying to track down all the tentacles of this quickly becomes very messy. What saves us at the moment is that SCHED_LOCK (which is used to protect parts of the signal state, but not all) happens to be recursive and forgives small and big errors. That's about to change. So instead of trying to hunt down all the locking problems here, just make hardclock not send signals. Instead hardclock schedules a timeout that will send the signal later. There are many reasons why this works just as good as the previous code, all explained in a comment written in big, friendly letters in kern_clock. miod@ ok noone else dared to ok this, but noone screamed in agony either.
2004-06-24This moves access to wall and uptime variables in MI code,Thorsten Lockert
encapsulating all such access into wall-defined functions that makes sure locking is done as needed. It also cleans up some uses of wall time vs. uptime some places, but there is sure to be more of these needed as well, particularily in MD code. Also, many current calls to microtime() should probably be changed to getmicrotime(), or to the {,get}microuptime() versions. ok art@ deraadt@ aaron@ matthieu@ beck@ sturm@ millert@ others "Oh, that is not your problem!" from miod@
2004-06-13debranch SMP, have funNiklas Hallqvist
2004-06-09Merge in a piece of the SMP branch into HEAD.Artur Grabowski
Introduce the cpu_info structure, p_cpu field in struct proc and global scheduling context and various changed code to deal with this. At the moment no architecture uses this stuff yet, but it will allow us slow and controlled migration to the new APIs. All new code is ifdef:ed out. ok deraadt@ niklas@
2004-06-05retval may be NULL in fork1, take 2Ted Unangst
2004-05-24No way: This breaks nearly every architectureTheo de Raadt
2004-05-23according to fork1(9), retval is optional. make it so.Ted Unangst
from form@pdp-11.org.ru via mpech. ok millert
2004-04-02rfork(RFMEM) shares complete vmspace. much more useful, and in line withTed Unangst
other projects' implementations.
2003-09-23Limit "proc: table is full" messages to once every 10 seconds which helps ↵Todd C. Miller
when there is a fork bomb going on. From NetBSD (jdolecek)
2003-07-02comitted->committed in a commentAnil Madhavapeddy
2003-06-21add exec/fork/exit hooks per process for compat emulations.Ted Unangst
use them to correctly emulate linux brk. update to TNF copyright in linux_exec.c. from netbsd, mostly from a diff by Kurt Miller in pr3318. this should fix java. no regressions in testing by kurt and sturm@. be prepared for "proc size mismatch" -- recompile ps and friends. ok deraadt@
2003-06-02Remove the advertising clause in the UCB license which BerkeleyTodd C. Miller
rescinded 22 July 1999. Proofed by myself and Theo.
2002-10-31Defer pid allocation and making the new process visible until after it'sArtur Grabowski
been fully initialized. Otherwise the scheduler and other things can accidentally stumble into semi-initialized processes and strange things can happen. This also requires us to do systrace attachment a bit later. Debugging help from fgs@
2002-10-22Remove a part that did sneak in that wasn't meant to be commited yet.Artur Grabowski
2002-10-21ANSIArtur Grabowski
2002-10-21Two problems.Artur Grabowski
First we check for running out of processes (nprocs variable) before we continue with the fork, then we do various calls that might sleep (and allow other forks to start and pass that check), then we increase that variable. This could allow processes to be created past the limit. Second is that we don't decrease the the process count for this uid if the stack allocation fails. So a user could run out of processes he's allowed to run without actually having them. miod@ ok
2002-05-16systrace facility, used to enforce and generate policies for system callsNiels Provos
okay deraadt@
2002-03-14First round of __P removal in sysTodd C. Miller
2002-02-22Fix stack sharing in FORK_VMNOSTACK.Artur Grabowski
Don't assume that the stack is on the top of user address space. And don't assume that the stack grows down.
2002-02-16Simplify pid selection algorithm. ok art@ deraadt@Thomas Nordin
2002-02-14No more RFORK_FDSAHRE option, always allow FORK_SHAREFILES.Artur Grabowski
2002-02-05Workaround for VM_MAXUSER_ADDRESS not being page aligned on sparc64.Artur Grabowski
2002-01-25poolify pcreds.Artur Grabowski
2002-01-16Don't include <sys/map.h> when you don't need what's in it.Miod Vallat
2001-11-06Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.Miod Vallat
(Look ma, I might have broken the tree)
2001-11-06Let fork1, uvm_fork, and cpu_fork take a function/argument pair as argument,Artur Grabowski
instead of doing fork1, cpu_set_kpc. This lets us retire cpu_set_kpc and avoid a multiprocessor race. This commit breaks vax because it doesn't look like any other arch, someone working on vax might want to look at this and try to adapt the code to be more like the rest of the world. Idea and uvm parts from NetBSD.
2001-11-06More sync to NetBSD.Artur Grabowski
- Use malloc/free instead of MALLOC/FREE for variable sized allocations. - Move the memory inheritance code to sys/mman.h and rename from VM_* to MAP_* - various cleanups and simplifications.
2001-10-14Disable fd sharing for this release. Sorry.Artur Grabowski
deraadt@ ok.
2001-09-19merge vm/vm_kern.h into uvm/uvm_extern.h; art@ okMichael Shalayeff
2001-06-27no more fork braindamageArtur Grabowski
2001-06-27mips_cachealias is no moreArtur Grabowski
2001-06-27remove old vmArtur Grabowski
2001-04-02On popular demand, the Linux-compatibility clone(2) implementation basedNiklas Hallqvist
on NetBSD's code, as well as some faked Posix RT extensions by me. This makes at least simple linuxthreads tests work.
2001-03-23Use pool to allocate processes.Artur Grabowski