summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
Commit message (Collapse)AuthorAgeFilesLines
* T -CURRENT DO NOT CRASH UPON ^T K PLZ THX.green2004-02-141-1/+2
| | | | Also, use sched_pctcpu() instead of assuming td->td_kse is non-NULL.
* A variety of further cleanups to ttyinfo():rwatson2004-02-041-77/+84
| | | | | | | | | | | | | | | | | | | | | | | | | - Rename temporary variable names ("tmp", "tmp2") to more informative names ("load", "pctcpu", "rss", ...) - Unclutter indentation and return paths: rather than lots of nested ifs, simply return earlier if it's not going to work out. Simplify general structure and avoid "deep" code. - Comment on the thread/process selection and locking. - Correct handling of "running"/"runnable" states, avoid "unknown" that people were seeing for running processes. This was due to a misunderstanding of the more complex state machine / inhibitors behavior of KSE. - Do perform ttyinfo() printing on KSE (P_SA) processes, it seems generally to work. While I initially attempted to formulate this as two commits (one layout, the other content), I concluded that the layout changes were really structural changes. Many elements submitted by: bde
* Improve the expressiveness of ttyinfo (^T) when dealing with threadsrwatson2004-01-081-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | in slightly less usual states: If the thread is on a run queue, display "running" if the thread is actually running, otherwise, "runnable". If the thread is sleeping, and it's on a sleep queue, display the name of the queue, otherwise "unknown" -- previously, in this situation we would display "iowait". If the thread is waiting on a lock, display *lockname. If the thread is suspended, display "suspended" -- previously, in this situation we would display "iowait". If the thread is waiting for an interrupt, display "intrwait" -- previously, in this situation we would display "iowait". If the thread is in a state not handled by the above, display "unknown" -- previously, we would print "iowait". Among other things, this avoids displaying "iowait" when the foreground process turns out to be suspended waiting for a debugger to properly attach.
* - Implement selwakeuppri() which allows raising the priority of atanimura2003-11-091-2/+2
| | | | | | | | | | | | | thread being waken up. The thread waken up can run at a priority as high as after tsleep(). - Replace selwakeup()s with selwakeuppri()s and pass appropriate priorities. - Add cv_broadcastpri() which raises the priority of the broadcast threads. Used by selwakeuppri() if collision occurs. Not objected in: -arch, -current
* Use a new message buffer `consmsgbuf' to forward messages to aiedowse2003-06-221-3/+3
| | | | | | | | | | | | | | | TIOCCONS console (e.g. xconsole) via a timeout routine instead of calling into the tty code directly from printf(). This fixes a number of cases where calling printf() at the wrong time (such as with locks held) would cause a panic if xconsole is running. The TIOCCONS message buffer is 8k in size by default, but this can be changed with the kern.consmsgbuf_size sysctl. By default, messages are checked for 5 times per second. The timer runs and the buffer memory remains allocated only at times when a TIOCCONS console is active. Discussed on: freebsd-arch
* Rename P_THREADED to P_SA. P_SA means a process is using schedulerdavidxu2003-06-151-1/+1
| | | | activations.
* Use __FBSDID().obrien2003-06-111-1/+3
|
* p_sigignore moved into struct sigacts. move one which was missed.ps2003-05-141-1/+1
| | | | Approved by: re (scottl)
* - Merge struct procsig with struct sigacts.jhb2003-05-131-2/+2
| | | | | | | | | | | | | | | | | - 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)
* - Use a local struct proc variable to improve readability.jhb2003-04-171-11/+11
| | | | | - Use a local variable to close a minor race when determining if the wmesg printed out needs a prefix such as when a thread is blocked on a lock.
* - Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread withjeff2003-03-311-13/+19
| | | | | | | 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.
* Make TTYHOG tunable.das2003-03-051-0/+1
| | | | Reviewed by: mike (mentor)
* Change the process flags P_KSES to be P_THREADED.julian2003-02-271-1/+1
| | | | 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 #include <sys/dkstat.h>phk2003-02-161-1/+0
|
* Move the tty related statistics counters to live with the tty code.phk2003-02-161-0/+5
|
* Lock the proc around accessing p_siglist in ttycheckoutq() in thetjr2003-02-101-3/+14
| | | | unused wait != 0 case.
* 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.
* In an SMP environment post-Giant it is no longer safe to blindlytruckman2002-10-031-1/+1
| | | | | | | | | dereference the struct sigio pointer without any locking. Change fgetown() to take a reference to the pointer instead of a copy of the pointer and call SIGIO_LOCK() before copying the pointer and dereferencing it. Reviewed by: rwatson
* Rename the mutex thread and process states to use a more generic 'LOCK'jhb2002-10-021-3/+3
| | | | | | | | | 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.
* Back our kernel support for reliable signal queues.jmallett2002-10-011-9/+5
| | | | Requested by: rwatson, phk, and many others
* First half of implementation of ksiginfo, signal queues, and such. Thisjmallett2002-09-301-5/+9
| | | | | | | | | | | | | | | | | | | | | | 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]
* Completely redo thread states.julian2002-09-111-6/+7
| | | | Reviewed by: davidxu@freebsd.org
* Clear up confusion in ugly code. ^T gave wrong results for RSS.julian2002-07-181-4/+9
| | | | | | I misinterpretted this code when changing it to handle threads. (there are still issues here) Submitted by: Ian Dowse <iedowse@maths.tcd.ie>
* Part 1 of KSE-IIIjulian2002-06-291-10/+43
| | | | | | | | | | | | | 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..
* Display the mutex name in the ^T status line if the selected threadiedowse2002-06-201-2/+3
| | | | | is blocked on a mutex. Prepend a '*' to distinguish this case as is done in top(1).
* Nit: kern.ttys is of type S,xtty, not S,tty.des2002-05-311-1/+1
|
* Add some checks to prevent NULL dereferences.des2002-05-281-3/+6
| | | | Submitted by: jhay
* Add NAI copyright.des2002-05-281-0/+8
|
* Introduce struct xtty, used when exporting tty information to userland.des2002-05-281-5/+30
| | | | | | | Make kern.ttys export a struct xtty rather than struct tty. Since struct tty is no longer exposed to userland, remove the dev_t / udev_t hack. Sponsored by: DARPA, NAI Labs
* ANSIfy (significant portions were already partly ANSIfied)des2002-05-251-115/+42
|
* Remove register.des2002-05-251-51/+51
|
* Automated whitespace cleanup.des2002-05-251-10/+10
|
* Make funsetown() take a 'struct sigio **' so that the locking canalfred2002-05-061-1/+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.
* Redo the sigio locking.alfred2002-05-011-2/+2
| | | | | | | | | | | Turn the sigio sx into a mutex. Sigio lock is really only needed to protect interrupts from dereferencing the sigio pointer in an object when the sigio itself is being destroyed. In order to do this in the most unintrusive manner change pgsigio's sigio * argument into a **, that way we can lock internally to the function.
* - Lock proctree_lock instead of pgrpsess_lock.jhb2002-04-161-33/+34
| | | | | | - Use temporary variables to hold a pointer to a pgrp while we dink with it while not holding either the associated proc lock or proctree_lock. It is in theory possible that p->p_pgrp could change out from under us.
* Dike out a highly insecure UCONSOLE option.ru2002-04-031-4/+14
| | | | | | TIOCCONS must be able to VOP_ACCESS() /dev/console to succeed. Obtained from: OpenBSD
* Fix leakage of p_pgrp lock.tanimura2002-04-021-1/+1
|
* Change the suser() API to take advantage of td_ucred as well as do ajhb2002-04-011-5/+7
| | | | | | | | | | | | general cleanup of the API. The entire API now consists of two functions similar to the pre-KSE API. The suser() function takes a thread pointer as its only argument. The td_ucred member of this thread must be valid so the only valid thread pointers are curthread and a few kernel threads such as thread0. The suser_cred() function takes a pointer to a struct ucred as its first argument and an integer flag as its second argument. The flag is currently only used for the PRISON_ROOT flag. Discussed on: smp@
* Remove __P.alfred2002-03-191-14/+14
|
* Fixes to make select/poll mpsafe.alfred2002-03-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: selwakeup required calling pfind which would cause lock order reversals with the allproc_lock and the per-process filedesc lock. Solution: Instead of recording the pid of the select()'ing process into the selinfo structure, actually record a pointer to the thread. To avoid dereferencing a bad address all the selinfo structures that are in use by a thread are kept in a list hung off the thread (protected by sellock). When a selwakeup occurs the selinfo is removed from that threads list, it is also removed on the way out of select or poll where the thread will traverse its list removing all the selinfos from its own list. Problem: Previously the PROC_LOCK was used to provide the mutual exclusion needed to ensure proper locking, this couldn't work because there was a single condvar used for select and poll and condvars can only be used with a single mutex. Solution: Introduce a global mutex 'sellock' which is used to provide mutual exclusion when recording events to wait on as well as performing notification when an event occurs. Interesting note: schedlock is required to manipulate the per-thread TDF_SELECT flag, however if given its own field it would not need schedlock, also because TDF_SELECT is only manipulated under sellock one doesn't actually use schedlock for syncronization, only to protect against corruption. Proc locks are no longer used in select/poll. Portions contributed by: davidc
* Stop abusing the pgrpsess_lock.tanimura2002-03-111-3/+3
|
* Fix lock leakage and late unlock.tanimura2002-03-021-3/+3
| | | | Submitted by: bde
* Fix a typo (?) in previous commit told ttyprintf() to print the integerphk2002-02-241-1/+1
| | | | | part of the user-time as a 64bit quantity. This resulted in weird output from SIGINFO.
* Lock struct pgrp, session and sigio.tanimura2002-02-231-53/+142
| | | | | | | | | | | | | | | | | | | | | | | | | New locks are: - pgrpsess_lock which locks the whole pgrps and sessions, - pg_mtx which protects the pgrp members, and - s_mtx which protects the session members. Please refer to sys/proc.h for the coverage of these locks. Changes on the pgrp/session interface: - pgfind() needs the pgrpsess_lock held. - The caller of enterpgrp() is responsible to allocate a new pgrp and session. - Call enterthispgrp() in order to enter an existing pgrp. - pgsignal() requires a pgrp lock held. Reviewed by: jhb, alfred Tested on: cvsup.jp.FreeBSD.org (which is a quad-CPU machine running -current)
* Fix a couple of style bugs introduced (or touched by) previous commit.peter2002-02-071-2/+0
|
* Pre-KSE/M3 commit.julian2002-02-071-1/+5
| | | | | | | | | | this is a low-functionality change that changes the kernel to access the main thread of a process via the linked list of threads rather than assuming that it is embedded in the process. It IS still embeded there but remove all teh code that assumes that in preparation for the next commit which will actually move it out. Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
* utime/stime.tv_sec are elapsed times, not relative to 1970. We canpeter2001-11-171-4/+4
| | | | | safely print them as longs. Even if ^T overflows after a process has accumulated 68 years of user or system time, it is no big deal.
* You cannot cast a time_t to quad_t and printf it with %lld. quad_t ispeter2001-11-161-2/+2
| | | | 64 bits, not long long.
* o Move suser() calls in kern/ to using suser_xxx() with an explicitrwatson2001-11-011-4/+4
| | | | | | | | | credential selection, rather than reference via a thread or process pointer. This is part of a gradual migration to suser() accepting a struct ucred instead of a struct proc, simplifying the reference and locking semantics of suser(). Obtained from: TrustedBSD Project
OpenPOWER on IntegriCloud