Commit graph

56001 commits

Author SHA1 Message Date
Daniel Eischen d201fe46e3 Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread
functions.  If the threads library is linked in, the real
pthread functions will pulled in.

Use the following convention for system calls wrapped by the
threads library:
	__sys_foo - actual system call
	_foo - weak definition to __sys_foo
	foo - weak definition to __sys_foo

Change all libc uses of system calls wrapped by the threads
library from foo to _foo.  In order to define the prototypes
for _foo(), we introduce namespace.h and un-namespace.h
(suggested by bde).  All files that need to reference these
system calls, should include namespace.h before any standard
includes, then include un-namespace.h after the standard
includes and before any local includes.  <db.h> is an exception
and shouldn't be included in between namespace.h and
un-namespace.h  namespace.h will define foo to _foo, and
un-namespace.h will undefine foo.

Try to eliminate some of the recursive calls to MT-safe
functions in libc/stdio in preparation for adding a mutex
to FILE.  We have recursive mutexes, but would like to avoid
using them if possible.

Remove uneeded includes of <errno.h> from a few files.

Add $FreeBSD$ to a few files in order to pass commitprep.

Approved by:	-arch
2001-01-24 13:01:12 +00:00
John Baldwin e0aa5ab718 - Catch up to new proc flags. 2001-01-24 12:59:50 +00:00
John Baldwin 6d3e7b9b0b Add a new item to kinfo_proc: ki_sflag to mirror p_sflag. 2001-01-24 12:49:52 +00:00
Jason Evans 1b367556b5 Convert all simplelocks to mutexes and remove the simplelock implementations. 2001-01-24 12:35:55 +00:00
John Baldwin 69b4045657 Argh, I didn't get this test right when I converted it. Break this up
into two separate if's instead of nested if's.  Also, reorder things
slightly to avoid unnecessary mutex operations.
2001-01-24 12:23:17 +00:00
Ruslan Ermilov f6f24f55c3 mdoc(7) police: Remove the debug line that prevents hyphenation
for the purposes of spelling checking that left in after my last
visit to this file.
2001-01-24 12:22:39 +00:00
John Baldwin 8606d88043 - Catch up to proc flag changes.
- Minimal proc locking.
- Use queue macros.
2001-01-24 11:28:36 +00:00
John Baldwin e2181d41d0 Add mtx_assert()'s to verify that kmem_alloc() and kmem_free() are called
with Giant held.
2001-01-24 11:27:29 +00:00
John Baldwin 5074aecd6c - Catch up to proc flag changes.
- Proc locking in a few places.
- faultin() now must be called with the proc lock held.
- Split up swappable() into a couple of tests so that it can be locke in
  swapout_procs().
- Use queue macros.
2001-01-24 11:25:56 +00:00
John Baldwin b939335607 - Catch up to proc flag changes. 2001-01-24 11:20:05 +00:00
John Baldwin 168666be74 - Catch up to proc flag changes.
- Assert sched_lock is held in proc_compare.
2001-01-24 11:15:59 +00:00
John Baldwin 3897ca7c61 - Catch up to proc flag changes.
- Update stopevent() to assert that the proc lock is held when it is
  held and is not recursed.  Note that the STOPEVENT() macro obtains
  the proc lock when calling this function.
2001-01-24 11:15:24 +00:00
John Baldwin e04ac2fe6b - Catch up to proc flag changes.
- Add proc locking for selwakeup() and selrecord().
2001-01-24 11:12:37 +00:00
John Baldwin ec5a741d77 - Catch up to proc flag changes. 2001-01-24 11:11:35 +00:00
John Baldwin 1899325c72 - Catch up to proc flag changes.
- Add in some locking ops that might fix SIGXCPU, but don't enable them
  yet.
- Assert that sched_lock is not recursed when mi_switch() is called.
2001-01-24 11:10:55 +00:00
John Baldwin 40447cd4aa - Proc locking.
- Catch up to proc flag changes.
2001-01-24 11:08:02 +00:00
John Baldwin 7871c121ff - Add a mtx_assert() for sched_lock in calcru().
- Protect calcru() with sched_lock later on in the file when it is called.
2001-01-24 11:06:39 +00:00
John Baldwin 42a4ed9975 - Proc locking.
- Catch up to proc flag changes.
- Reorder the way we get things in fill_kinfoproc() to minimize the
  number of locking operations.
2001-01-24 11:05:50 +00:00
John Baldwin 8484de7555 - Don't use a union and fun tricks to shave one extra pointer off of struct
mtx right now as it makes debugging harder.  When we are in optimizing
  mode, we can revisit this.
- Fix the KTR trace messages to use %p rather than 0x%p to avoid duplicate
  0x's in KTR output.
- During witness_fixup, release Giant so that witness doesn't get confused.
  Also, grab all_mtx while walking the list of mutexes.
- Remove w_sleep and w_recurse.  Instead, perform checks on mutexes using
  the mutex's mtx_flags field.
- Allow debug.witness_ddb and debug.witness_skipspin to be set from the
  loader.
- Add Giant to the front of existing order_list entries to help ensure
  Giant is always first.
- Add an order entry for the various proc locks.  Note that this only
  helps keep proc in order mostly as the allproc and proctree mutexes are
  only obtained during a lockmgr operation on the specified mutex.
2001-01-24 10:57:01 +00:00
John Baldwin f1dea27db4 - Catch up to proc flag changes.
- Set the new P_KTHREAD flag for kthreads during kthread_create.
2001-01-24 10:47:50 +00:00
John Baldwin a7b124c3c7 - Catch up to proc flag changes.
- Add new fork_exit() and fork_return() MI C functions.
2001-01-24 10:47:14 +00:00
John Baldwin 981808d145 Catch up to P_FOO -> PS_FOO changes in proc flags. 2001-01-24 10:44:01 +00:00
John Baldwin 01cd094c32 - Proc locking.
- P_FOO -> PS_FOO.
2001-01-24 10:43:25 +00:00
John Baldwin f202965e95 - Catch up to p_sflag changes.
- The MD code now initializes proc0.p_heldmtx, proc0.p_contested, and
  curproc.
- The MD code calls here with Giant already held.
- Proc locking.
2001-01-24 10:40:56 +00:00
John Baldwin a8a3dd2bb5 - Proc locking.
- P_OWEUPC -> PS_OWEUPC.
2001-01-24 10:38:58 +00:00
John Baldwin a467939095 - Proc locking.
- Update userret() to take a struct trapframe * as a second argument.
- Axe have_giant and use mtx_owned(&Giant) where appropriate.
2001-01-24 10:38:13 +00:00
John Baldwin 88541b72b7 - Proc locking.
- P_FOO -> PS_FOO.
2001-01-24 10:36:47 +00:00
John Baldwin 89db405712 - Proc locking.
- Bring across forwarded_statclock() fixes from i386 and alpha.
2001-01-24 10:36:21 +00:00
John Baldwin e7d904a13a - Proc locking around the vinumdaemon dinking with its flags.
- P_INMEM -> PS_INMEM.
2001-01-24 10:28:19 +00:00
John Baldwin 2ae8bab0b6 Make mp_machdep.c be an optional file conditional on SMP. 2001-01-24 10:27:37 +00:00
John Baldwin 60bb997eb3 Proc locking. 2001-01-24 10:27:11 +00:00
John Baldwin ee7a93c9ab Use queue macros. 2001-01-24 10:26:51 +00:00
John Baldwin fb8d5b0534 Add a prototype for isa_irq_mask() to quiet a warning. 2001-01-24 10:25:44 +00:00
John Baldwin fc15ff1a64 Wrap the IPI definitions and function prototypes in #ifdef SMP. 2001-01-24 10:25:09 +00:00
John Baldwin c6f6b7292b - Rename the gd_cpuno member of struct globaldata to gd_cpuid.
- Add a globaldata_register() prototype in the SMP case.
2001-01-24 10:24:49 +00:00
John Baldwin e62be0bfe7 - Proc locking.
- P_OWEUPC -> PS_OWEUPC.
2001-01-24 10:23:54 +00:00
John Baldwin a92ac5b9ae - Change userret() to take a struct trapframe * as its second argument and
to extract the PC from that to send to addupc_task() so that it can be
  called from MI code.
- Remove all traces of have_giant with extreme prejudice and use
  mtx_owned(&Giant) instead where appropriate.
- Proc locking.
- P_FOO -> PS_FOO.
- Don't grab Giant just to look in curproc's p_addr during a trap since we
  may choose to immediately exit.  Instead, delay grabbing Giant a bit
  until we actually need it.
- Don't reset 'p' to 'curproc' in syscall() to handle the case of a child
  returning from fork1() since children don't return via syscall().
- Remove an XXX comment in ast() that questions the correctness of the
  userland check.  The code is correct.
2001-01-24 10:23:21 +00:00
John Baldwin 1d64ccdcbb - Proc locking.
- P_INMEM -> PS_INMEM.
2001-01-24 10:16:23 +00:00
John Baldwin 0a8ec7a3bd - Proc locking.
- Don't send IPIs for pmap_invalidate_page() or pmap_invalidate_all()
  in the UP case.
- Catch up to cpuno -> cpuid.
- Convert some sanity checks that were #ifdef DIAGNOSTIC to KASSERT()'s.
2001-01-24 10:16:01 +00:00
John Baldwin 21f31719b6 - Adjust some whitespace to reduce diffs with the i386 version.
- Rename the per-CPU variable 'cpuno' to 'cpuid'.  This was done so that
  there is one consistent name across all architectures for a logical
  CPU id.
- Remove all traces of IRQ forwarding.
- Add globaldata_register() hook called by globaldata_init() to register
  globaldata structures in the cpuid_to_globaldata array.
- Catch up to P_FOO -> PS_FOO.
- Bring across some fixes for forwarded_statclock() from the i386 version
  to handle ithreads and idleproc properly.
- Rename addugd_intr_forwarded() to addupc_intr_forwarded() so that it is
  the same name on all architectures.
- Set flags in p_sflag instead of calling psignal() from
  forward_hardclock().
- Proc locking.
- When we handle an IPI, turn off its bit in the mask of IPI's we are
  currently handling so that an IPI doesn't send a CPU into an infinite
  loop.
2001-01-24 10:13:13 +00:00
John Baldwin caf46c8d44 - Initialize curproc, proc0.p_heldmtx, and proc0.p_contested earlier so
that mutex operations work.
- Enter Giant earlier so we hold it during boot.
- Proc locking.
- Move globaldata_init() into here from mp_machdep.c so that UP kernels
  don't depend on mp_machdep.c.  Use a callout in the SMP case to register
  the boot processor's globaldata in the cpuid_to_globaldata array.
2001-01-24 10:07:42 +00:00
John Baldwin 8929eb2c88 - Wrap the IPI interrupt handler in #ifdef SMP.
- Catch up to cpuno -> cpuid change.
- Add parens around a subexpression to quiet a warning.
2001-01-24 10:05:24 +00:00
John Baldwin 35d14e0f54 cpuno -> cpuid. 2001-01-24 10:04:32 +00:00
John Baldwin 30a62a81e3 Don't import the nonexistent astpending variable. 2001-01-24 10:03:05 +00:00
John Baldwin e4fb2bca29 Wrap the startup code used by secondary processors in #ifdef SMP. 2001-01-24 10:01:53 +00:00
John Baldwin bb4b2d8b2a Remove the Xforward_irq IPI. 2001-01-24 10:01:13 +00:00
John Baldwin cd60bc00a7 - Remove all the #if 0'd code that used to implement IRQ forwarding.
- Remove #if 0'd lazy interrupt mask.
2001-01-24 10:00:07 +00:00
John Baldwin 738a8dfba1 Remove unused locks: cpl, fast_intr, intr, mpintr. 2001-01-24 09:58:56 +00:00
John Baldwin 5b8c74d59a - Proc locking.
- P_OWEUPC -> PS_OWEUPC.
- Remove obsolete prototype for MD fork_return().
2001-01-24 09:56:49 +00:00
John Baldwin 019fb3becf - Remove Xforward_irq, cpl_lock, and fast_intr_lock.
- Add fork_exit.
2001-01-24 09:55:39 +00:00