From owner-p4-projects Fri Jun 28 15:52: 7 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 62EA537B40E; Fri, 28 Jun 2002 15:49:42 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0E42C37B4A1 for ; Fri, 28 Jun 2002 15:49:28 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id F0B6444073 for ; Fri, 28 Jun 2002 15:36:29 -0700 (PDT) (envelope-from julian@freebsd.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g5SMaTJU031847 for ; Fri, 28 Jun 2002 15:36:29 -0700 (PDT) (envelope-from julian@freebsd.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g5SMaTbT031844 for perforce@freebsd.org; Fri, 28 Jun 2002 15:36:29 -0700 (PDT) Date: Fri, 28 Jun 2002 15:36:29 -0700 (PDT) Message-Id: <200206282236.g5SMaTbT031844@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to julian@freebsd.org using -f From: Julian Elischer Subject: PERFORCE change 13539 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=13539 Change 13539 by julian@julian_ref on 2002/06/28 15:36:04 try get a bit up to date Affected files ... .. //depot/projects/kse/sys/notes#12 edit Differences ... ==== //depot/projects/kse/sys/notes#12 (text+ko) ==== @@ -1,13 +1,15 @@ This file is to keep notes on what is going on re: KSEing the kernel. [STOPPED/SUSPEND] -WHen a process is 'stopped' thread that are in system calls +When a process is 'stopped', threads that are in a system call and may hold resources must be allowed to complete, however from the point of -view of teh rest of the world, the process is stopped if we do not allow +view of the rest of the world, the process is stopped if we do not allow any threads to go to user land. This means that we can implement 'stop' by taking any threads that wish to go to userland, and hanging them off a special suspended queue, and NOT letting them go to userland. +[done] + -------------------------------- More STOPs There are 4 basic kinds of stop that must be dealt with: @@ -15,15 +17,26 @@ ((p->p_userthreads == 0) && (p->p_flag & P_STOPPED_SGNL)) i.e no user threads are allowed and they are presenlty all not there. +[p_userthreads does not yet exist] +[presently use p_numthreads == p_suspcount] + 2/ Singlethreading: A process can generally only be considered safely singlethreaded when the state of all other threads is KNOWN to be "suspended". This can be needed for safe completion of some syscalls (e.g. fork) however the variant needed for exit and exec must force the other threads to actually die. This actually must occur in a safe place, e.g. the SUSPEND checkpoint. +The singlethreading thread will itself suspend until all other threads +are suspended. thus the completion state is p_numthreads == p_suspcount. +Either p_numthreads or p_suspcount can be chenged to reach this condition. + It is possible that for fork() a NON_KILLING singlethreading need only keep the threads out of userspace if there were no effort to -restart the threads in the child. The child would need to +restart the threads in the child. +[no probably they need to be suspended so that the child gets +a consistent image of memeory][hmmm maybe not.. think more] + +The child would need to complete all the context blocks in it's own space with a set of known failure codes, before completing the first upcall. The parent would be allowed to have it's threads in any state, suspended @@ -42,7 +55,7 @@ STOPPING mode, it requires the same notification of the parent that would occur when the TRACE suspencion is completed -5/ Embedded breakpoint: the thread is stopped. WHether the rest of the +4A/ Embedded breakpoint: the thread is stopped. WHether the rest of the threads are stopped is dependent on what is required. ----------------------- @@ -55,14 +68,15 @@ Thus they must not take part in the 'assigned thread' system. Such a thread and KSE combination becomes 'synchronous'. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^VIP +[Done (in part) see "BOUND" mode (TDF_UNBOUND)] SWAPPING In swapping, the function faultin() in vm_glue.c is the one to start investigations with. pmap_swapin_proc() and pmap_swapin_thread() are used and are synchronous. -Thus a processes hreads are either all-in or potentially all-out +Thus a processes threads are either all-in or potentially all-out of memory. The act of swapping a process in, ensures that they are -all in memory. +all in memory. [CHECK THIS] Note cached threads must be unswapped and in fact I believe that can only be so in this code. Thread-free() is only called as part of @@ -76,7 +90,7 @@ SINGLE_THREADING -This is a variant of SSTOP/SUSPEND. where on thread is allowed to continue +This is a variant of SSTOP/SUSPEND. where one thread is allowed to continue operation. (since it will never enter userland in this state that is normal). The difference is that the master thread is awoken when all other threads have become suspended (or exited) @@ -87,14 +101,17 @@ EXIT exit1 needs to set up the single threading. Set a flag that makes all threads entering or exiting the kernel -abort. ALso examined at other points (e.g. tsleep)/wake etc. +abort. Also examined at other points (e.g. tsleep)/wake etc. Possibly send a signal-like wakeup to all PCATCH sleeping threads. exiting needs to have a flag rather than be a state. The state is RUNNING (usually). ALready exists.. P_WEXIT. The single-threading mode may be enough. **The exit's own KSE should be freed to exit other threads while it waits** +[This brings up the whole concept of KSE BORROWING or LENDING.. see later] + FORK. +The grand plan... The singlethreading pointer points to the only thread that can act normally at this time. All other threads will proceed to the userland interface and write out results and return values asap. They may even abort @@ -114,7 +131,7 @@ you want them to suspend BEFORE they write out their status because that would perterb the parent address space that you are duplicating, The results of a read() are ok, but the tcbs shouldn't be filled out and -moved to teh completed queue, because the child needs to do them differently. +moved to the completed queue, because the child needs to do them differently. @@ -146,11 +163,12 @@ setrunqueue(td); } +Usually this is done with a priority change.. +should really take the new peiority as an argument. + All the sleeptime stats are screwed up between threads, KSEs and KSEGRPs - - WAKEUP/setrunqueue in wakeup() in the !INMEM case, I've probably broken it by @@ -167,5 +185,3 @@ cannot be touched during wakeup as the thread may not have a KSE. find out what it's for and think of a better way of doing it. -[kg_runnable] -is never decremented.. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message