Commit Graph

90074 Commits

Author SHA1 Message Date
Justin T. Gibbs
92931c12ff Correct/Simplify ignore wide residue message handling
aic7xxx.c:
	In ahc_handle_ign_wide_residue():
	o Use SCB_XFERLEN_ODD SCB field to determine transfer
	  "oddness" rather than the DATA_COUNT_ODD logic.
	  SCB_XFERLEN_ODD is toggled on every ignore wide
	  residue message so that multiple ignore wide residue
	  messages for the same transaction are properly supported.
	o If the sg list has been exausted, the sequencer
	  doesn't bother to update the residual data count
	  since it is known to be zero.  Perform the zeroing
	  manually before calculating the remaining data count.
	o Ensure that SG_LIST_NULL is cleared in the
	  residual sg pointer for "mid-transfer" ignore
	  wide residue cases.
	o Use multibyte in/out macros instead of shifting/masking
	  by hand.

aic7xxx.h:
	Modify the SCB_GET_LUN() macro to mask the lun hardware
	SCB field with LID.  This leaves two bits in the LUN
	field that can be used for other purposes.

aic7xxx.reg:
	Change LID to be 0x3F.  This is the maximum supported
	lun size for non-packetized SCSI.  Map the top bit
	of the lun to SCB_XFERLEN_ODD.  The host must set
	this bit whenever a transfer is an odd length.

	Remove the ODD_SEG bit field that was used to carry the odd
	transfer length information through the SG cache.  This
	is obviated by SCB_XFERLEN_ODD field.

	Remove the DATA_COUNT_ODD scratch ram byte that was used
	dynamicaly compute data transfer oddness.  This is obviated
	by SCB_XFERLEN_ODD field.

aic7xxx.seq:
	Be more careful in our handling of the SCB_LUN field.  It
	must be masked with LID if only lun information is desired.

	Remove all updates to the DATA_COUNT_ODD scratch ram field.
	Remove all uses of ODD_SEG.  These two save quite a few
	sequencer instructions.

	Use SCB_XFERLEN_ODD to validate the end of transfer
	ignore wide residue message case.

aic7xxx_inline.h:
	In ahc_queue_scb(), setup the SCB_XFERLEN_ODD field.

Approved by: RE
2003-05-26 21:24:01 +00:00
Justin T. Gibbs
e4e6e6d6ea Fix disabling of PCI parity error interrupts. We need to set
FAILDIS in the SEQCTL register, not the HCNTRL register.

aic7xxx.c:
	Remeber SEQCTL settings in the "seqctl" field of our
	softc.  seqctl defaults to just having FASTMODE set,
	but the bus attachments can override this.

aic7xxx.h:
	Add the seqctl softc field.

aic7xxx_pci.c:
	Update the seqctl softc field and manually update SEQCTL
	when to many PCI errors occur

Approved by: RE
2003-05-26 21:20:47 +00:00
Justin T. Gibbs
a3f571b832 Change hadling of the Rev. A packetized lun output bug
to be more efficient by having the sequencer copy the
single byte of valid lun data into the long lun field.

aic79xx.c:
	Memset our hardware SCB to 0 so that untouched
	fields don't confuse diagnostic output.  With the
	old method for handling the Rev A bug, if the long
	lun field was not 0, this could result in bogus
	lun information being sent to drives.

	Use the same SCB transfer size for all chip types
	now that the long lun is not DMA'ed to the chip.

aic79xx.seq:
	Add code to copy lun information for Rev.A hardware.

aic79xx_inline.h:
	Remove host update of the long_lun field on every
	packetized command.
2003-05-26 21:18:48 +00:00
Justin T. Gibbs
197696e939 Add 7901B support.
Sort IDs based on chip type.

Remove IROC IDs.  We'll switch to using the IROC masks
if/when we want to start attaching to IROC controllers.

Approved by: RE
2003-05-26 21:15:52 +00:00
Justin T. Gibbs
8089f0f033 Fixup spelling of "coalesce" and derivatives.
Approved by: RE
2003-05-26 21:10:58 +00:00
Justin T. Gibbs
3baccea690 Remove stray K&R style function definition.
Approved by: RE
2003-05-26 21:09:15 +00:00
Mario Sergio Fujikawa Ferreira
fc12c41ca3 pkg_create incorrectly does not add trailing '\n' when it receives
either COMMENT or DESCR from the command line. When a port is
installed, one gets both +COMMENT and +DESCR files with a trailing
'\n' character. However, +COMMENT does not contain a trailing '\n'
when it is installed from a package due to this behavior of pkg_create.

 Therefore, make sure it behaves exactly the same regardless of
where got its information; either command line or files. The modified
functions are used by pkg_create.

PR:		52097
Reviewed by:	bento, kris,
		portmgr, re,
		Michael Nottebrock <michaelnottebrock@gmx.net>,
		Martin Horcicka <horcicka@FreeBSD.cz>
Approved by:	re (scottl)
MFC after:	1 week
2003-05-26 17:12:22 +00:00
Mario Sergio Fujikawa Ferreira
c32acd2e5c Add a trailing '\n' character if none is found in the information
obtained from a package. Patch show_file() [1] and show_index() [2]
functions.

PR:		52097
Reviewed by:	bento, kris,
		portmgr, re,
		Michael Nottebrock <michaelnottebrock@gmx.net>,
		Martin Horcicka <horcicka@FreeBSD.cz>
Approved by:	re (scottl)
Obtained from:	NetBSD [1],
		OpenBSD [2]
MFC after:	1 week
2003-05-26 17:06:05 +00:00
Scott Long
5cf33ce608 Fix two typos from the last commit 2003-05-26 16:59:00 +00:00
Hideyuki KURASHINA
e2bc3704d3 Merge the following from the English version:
1.12  -> 1.15	early-adopter/article.sgml
	1.143 -> 1.155	hardware/common/dev.sgml
	1.5   -> 1.6	hardware/common/intro.sgml
	1.9   -> 1.11	hardware/i386/proc-i386.sgml
	1.2   -> 1.3	hardware/ia64/article.sgml
	1.3   -> 1.7	hardware/ia64/proc-ia64.sgml
	1.6   -> 1.7	share/sgml/release.dsl

Approved by:	re (blanket)
2003-05-26 15:32:34 +00:00
Scott Long
0dccf2239d De-orbit bus_dmamem_alloc_size from here too.
Pointed out by:	des
Pointy hat to:	me
2003-05-26 14:38:48 +00:00
Dag-Erling Smørgrav
bb4bb09d45 Remember to close the read end of the pipe. 2003-05-26 12:12:45 +00:00
Matthew N. Dodd
caf357a2c8 Remove uninitialized local variable in favor of global.
PR:		 bin/52685
Submitted by:	 Alexander Nedotsukov <bland@mail.ru>
Approved by:	 re (scottl)
2003-05-26 04:58:26 +00:00
Scott Long
c87d464f28 De-orbit bus_dmamem_alloc_size(). It's a hack and was never used anyways.
No need for it to pollute the 5.x API any further.

Approved by:	re (bmah)
2003-05-26 04:00:52 +00:00
Mike Makonnen
ca1c469cc7 Decouple the thread stack [de]allocating functions from the 'dead threads list'
lock. It's not really necessary and we don't need the added complexity
or potential for deadlocks.

Approved by:	re/blanket libthr
2003-05-26 00:37:07 +00:00
Mike Makonnen
2387af9962 Revise the unlock order in _pthread_join(). Also, if the joined
thread is not dead, the join loop is guaranteed to execute at least
once, so there is no need to pick up the thread list lock after
we return from suspenstion only to release it after the loop.

Approved by:	re/blanket libthr
2003-05-26 00:28:49 +00:00
Mike Makonnen
12c407a424 Return gracefully, rather than aborting, when the maximum concurrent
threads per process has been reached. Return EAGAIN, as per spec.

Approved by:	re/blanket libthr
2003-05-25 22:40:57 +00:00
Peter Wemm
a9a0bbad19 Copy the va_list in sbuf_vprintf() before passing it to vsnprintf(),
because we could fail due to a small buffer and loop and rerun.  If this
happens, then the vsnprintf() will have already taken the arguments off
the va_list.  For i386 and others, this doesn't matter because the
va_list type is a passed as a copy.  But on powerpc and amd64, this is
fatal because the va_list is a reference to an external structure that
keeps the vararg state due to the more complicated argument passing system.
On amd64, arguments can be passed as follows:
First 6 int/pointer type arguments go in registers, the rest go on
  the memory stack.
Float and double are similar, except using SSE registers.
long double (80 bit precision) are similar except using the x87 stack.
Where the 'next argument' comes from depends on how many have been
processed so far and what type it is.  For amd64, gcc keeps this state
somewhere that is referenced by the va_list.

I found a description that showed the va_copy was required here:
http://mirrors.ccs.neu.edu/cgi-bin/unixhelp/man-cgi?va_end+9
The single unix spec doesn't mention va_copy() at all.

Anyway, the problem was that the sysctl kern.geom.conf* nodes would panic
due to walking off the end of the va_arg lists in vsnprintf.  A better fix
would be to have sbuf_vprintf() use a single pass and call kvprintf()
with a callback function that stored the results and grew the buffer
as needed.

Approved by:	re (scottl)
2003-05-25 19:03:08 +00:00
Jeff Roberson
0003d1b74e - Create a new lock, umtx_lock, for use instead of the proc lock for
protecting the umtx queues.  We can't use the proc lock because we need
   to hold the lock across calls to casuptr, which can fault.

Approved by:	re
2003-05-25 18:18:32 +00:00
Poul-Henning Kamp
43f0db6cc5 Don't do silly thing if the disk_create() event gets canceled.
Approved by:	re/scottl
2003-05-25 16:57:10 +00:00
Jeff Roberson
30fd5d085d - Reset the free ent to NULL if we have consumed the last free entry. This
fixes a problem where we would overwrite old data if we ran out of free
   entries.

Submitted by:	sam
Approved by:	re (scottl)
2003-05-25 08:48:42 +00:00
Mike Makonnen
d39d651258 _pthread_cancel() breaks the normal lock order of first locking the
joined and then the joiner thread. There isn't an easy (sane?) way
to make it use the correct order without introducing races involving
the target thread and finding which (active or dead) list it is on. So,
after locking the canceled thread it will try to lock the joined thread
and if it fails release the first lock and try again from the top.

Introduce a new function, _spintrylock, which is simply a wrapper arround
umtx_trylock(), to help accomplish this.

Approved by: re/blanket libthr
2003-05-25 08:48:11 +00:00
Mike Makonnen
4393f2c4ec Part of the last patch.
Modify the thread creation and thread searching routine
to lock the thread lists with the new locks instead of GIANT_LOCK.

Approved by:	re/blanket libthr
2003-05-25 08:35:37 +00:00
Mike Makonnen
71d09bc86a Start locking up the active and dead threads lists. The active threads
list is protected by a spinlock_t, but the dead list uses a pthread_mutex
because it is necessary to synchronize other threads with the garbage
collector thread. Lock/Unlock macros are used so it's easier to make
changes to the locks in the future.

The 'dead thread list' lock is intended to replace the gc mutex.
This doesn't have any practical ramifications. It simply makes it
clearer what the purpose of the lock is. The gc will use this lock,
instead of the gc mutex, to synchronize access to the dead list with
other threads.

Modify _pthread_exit() to use these two new locks instead of GIANT_LOCK,
and also to properly lock and protect thread state changes,
especially with respect to a joining thread.

The gc thread was also re-arranged to be more organized and less nested.

_pthread_join() was also modified to use the thread list locks. However,
locking and unlocking here needs special care because a thread could find
itself in a position where it's joining an exiting thread that is
waiting on the dead list lock, which this thread (joiner) holds. If the
joiner doesn't take care to lock *and* unlock in the same order they
(the joiner and the joinee) could deadlock against each other.

Approved by:	re/blanket libthr
2003-05-25 08:31:33 +00:00
Mike Makonnen
6a1899ed5c The libthr code makes use of higher-level primitives (pthread_mutex_t and
pthread_cond_t) internaly in addition to the low-level spinlock_t. The
garbage collector mutex and condition variable are two such examples. This
might lead to critical sections nested within critical sections. Implement
a reference counting mechanism so that signals are masked only on the first
entry and unmasked on the last exit.

I'm not sure I like the idea of nested critical sections, but if
the library is going to use the pthread primitives it might be necessary.

Approved by:	re/blanket libthr
2003-05-25 07:58:22 +00:00
Peter Wemm
7dd6838582 Add a pretty cheesy hack to avoid a gcc-3.2.2 ICE (internal compiler
error) on amd64 when doing pointer subtraction.  This bug is already
fixed in gcc-3.3 (waiting for after the branch), and the hack will be
backed out at the first opportunity.  This is in the ipv6 code path.

Approved by:  re (scottl)
2003-05-25 07:39:06 +00:00
Marcel Moolenaar
9e14b94e43 The struct mcontext has changed. It's using the register sets. Bring
this in line.
2003-05-25 06:49:19 +00:00
Don Lewis
263c8abeb9 Beat vnode locking in the NFS server code into submission. This change
is not pretty, but it fixes the code so that it no longer violates the
vnode locking rules in the VFS API and doesn't trip any of the locking
assertions enabled by the DEBUG_VFS_LOCKS kernel configuration option.
There is one report that this patch fixed a "locking against myself"
panic on an NFS server that was tripped by a diskless client.

Approved by:	re (scottl)
2003-05-25 06:17:33 +00:00
Don Lewis
a35e7eaa1a Always set the hardware parse bit in the IPCB structure when this
structure, which is new to the 82550 and 82551, is used to transmit
a packet.  This appears to fix the packet truncation problem that was
observed when using 82550-based fxp cards to transmit ICMP or fragmented
UDP packets of certain lengths which only had one to three bytes in the
second and final mbuf of the packet.  This matches a note in the "Intel
8255x 10/100 Mbps Ethernet Controller Family Open Source Software Developer
Manual", which says that the hardware parse bit should be set when sending
these types of packets.

There have also been unconfirmed reports of similar problems when
transmitting TCP packets, which should not be affected by the above
mentioned change because the hardware parse bit was already being set
if the stack requested hardware checksumming of the packet.  If the
problem remains, the use of the IPCB structure can be disabled to
cause the driver to fall back to using the older 82559 interface with
82550-based cards by setting
        hint.fxp.UNIT_NUMBER.ipcbxmit_disable
to a non-zero value at boot time, or using kenv to set this variable
before using kldload to load the fxp driver.

Approved by:	re (jhb)
2003-05-25 05:04:26 +00:00
Jun Kuriyama
723a084b88 Add textproc/opensp into $MINIMALDOCPORTS when openjade is used.
Reported by:	scottl (by alpha building breakage)
Approved by:	re (scottl)
2003-05-25 03:41:41 +00:00
Marcel Moolenaar
dc0545462e Now that we define user mode as any IP address that isn't in the
kernel's VA regions, we cannot limit the use of break-based
syscalls to user mode only. The signal trampolines are in the
gateway page, which is mapped into the process address space in
region 5 and thus is kernel space.

We don't special case the gateway page here. Allow break-based
syscalls from anywhere in the kernel VA space.

Approved by: re@ (blanket)
2003-05-25 01:01:28 +00:00
Warner Losh
f9aedaa4ba Ignore the 'must allocate below 1MB' flag for the TPL_BAR_REG. It is
set on realtek cards, but they work without it (and don't work with
it).  The standard seems to imply that this is just a hint anyway, so
this should be harmless.  It doesn't appear to be set on any other
cardbus cards that I have (or have seen).

This should make the rl based CardBus cards work again.  I've been
running it for about a month now.

Approved by: re@ (jhb)
2003-05-24 23:23:41 +00:00
Marcel Moolenaar
d7f827116f Fix a source of instability specific to an EPC userland. We return
to userland with interrupts disabled until we restore PSR. However,
it has been observed that interrupts do actually happen before they
are enabled again. This is a bit surprising and I don't know yet
what's going on exactly. Nevertheless, the code was not crafted
carefully enough to allow interrupts to happen and we could
clobber the kernel stack of another thread when interrupts did
happen.

This is what happens: we restore the (memory) stack pointer (sp)
and the register stack base prior to restoring ar.k6 and ar.k7.
This is not a problem if interrupts don't happen between setting
sp/ar.bspstore and ar.k6/ar.k7. Alas, interrupts can happen.
Since sp/ar.bspstore already point to the userland stacks, we
need to switch to the kernel stack in interrupt. However, ar.k6
and ar.k7 have not been set, which means that we were switching
to some unrelated kstack and happily clobbered the trapframe
present there if the thread to which the kstack belonged was
in kernel mode or otherwise we could have our trapframe clobbered
if that other thread enters the kernel. Nasty either way.

We now carefully restore ar.k6 prior to restoring ar.bspstore and
likewise for ar.k7 and sp. All we need is the guarantee that an
interrupt does not clobber ar.k6 or ar.k7 before we're back in
userland. That has been achieved by restoring ar.k6/ar.k7
unconditionally (see exception.s)

While here, remove the disabling of interrupts on EPC entry. It
was added as a way to "resolve" the crashes until it was understood
what was going on. I think I achieved the latter, so we can remove
the patch. Note that setting up a trapframe with interrupts
enabled has it's own share of corner cases, but it's better to
properly fixed those than to keep a mostly wrong patch around
because we're afraid to remove it...

Approved by: re@ (blanket)
2003-05-24 22:53:10 +00:00
Marcel Moolenaar
a7b90d80fc Be more careful how we restore interrupts. Don't rewrite most of the
PSR only to achieve setting PSR.i back to it's previous value. It
makes it impossible to change any of the 30+ other unrelated bits
when done between intr_disable() and intr_restore(). That's bad.

Instead have intr_disable() return 1 when interrupts were previously
enabled and 0 otherwise and only enable interrupts in intr_restore()
when given a non-0 value.

This change specifically disallows using intr_restore() to disable
interrupts. The reason is simple: interrupts only need to be restored
after they are being disabled, which means that intr_restore() is
called with interrupts disabled and we only need to enable them if
they were previously enabled.

This change does not fix any bugs, other than that it bugged me...

Approved by: re@ (blanket)
2003-05-24 21:44:24 +00:00
Marcel Moolenaar
95f2dbba40 Consistently us the same metric to differentiate between kernel mode
and user mode. We need to take into account that the EPC syscall path
introduces a grey area in which one can argue either way, including a
third: neither.

We now use the region in which the IP address lies. Regions 5, 6 and 7
are kernel VA regions and if the IP lies any any of those regions we
assume we're in kernel mode. Hence, we can be in kernel mode even if
we're not on the kernel stack and/or have user privileges. There're
gremlins living in the twilight zone :-)

For the EPC syscall path this particularly means that the process
leaves user mode the moment it calls into the gateway page. This
makes the most sense because from a process' point of view the call
represents a request to the kernel for some service and that service
has been performed if the call returns. With the metric we picked,
this also means that we're back in user mode IFF the call returns.

Approved by: re@ (blanket)
2003-05-24 21:16:19 +00:00
Peter Wemm
5e8db10ac1 Add __amd64__ ifdefs to enable the bootblock handling code, slices, etc.
Approved by:	re (murray)
Obtained from:	obrien
2003-05-24 21:12:14 +00:00
Peter Wemm
cd51f0035e Add a temporary indirect patch for gcc when targeting amd64. This is to
give the cvs tree a surviving a 'make world'.  One of the two diff chunks
is already in gcc-3.3, the other has been committed to gcc's HEAD and
is in the pipeline for gcc-3.3.1 (but has not been committed yet).

The first chunk simplifies an excessively complex assembler statement
when generating switch jump tables.  The use of '.' causes as(1) to choke
on big files.  Use a simpler form instead.  This is only an issue for
TARGET_64BIT mode.

The second chunk fixes an internal compiler error when compiling
libc/stdio/vfprinf.c.  While this is supposedly only an issue for
64 bit mode, it does touch the 32 bit i386 code paths, so this patch
is only applied for TARGET_ARCH == amd64 to keep the risks down.
Breaking gcc at the 11th hour would suck.

This will be removed when it is time to import gcc-3.3.

Discussed with:	kan
Approved by:	re (jhb)
2003-05-24 20:58:47 +00:00
Marcel Moolenaar
fb4aa34f3b Unconditionally restore ar.k7 (memory stack) and ar.k6 (register stack)
when returning from an interrupt. Both registers are used on interrupt
to switch to the right kernel stack, but other than that they are not
used. This means we only have to make sure they contain proper values
while in user mode. As such, we conditionally restored these registers
based on whether we returned to userland or not. A nice property of
conditionally restoring ar.k6 and ar.k7 is that it introduces two
invariants: ar.k6 always points to the bottom of the kernel stack and
ar.k7 always points to the top of the kernel stack (immediately below
the PCB we have there).

However, the EPC syscall path introduces an irregularity: there's no
"thin red line" between user and kernel. There's a grey area that's a
couple of instructions wide. Any interruption in that grey area is
bound to see an inconsistent state. One such state is that we're in
kernel space for all practical purposes, but we still need to have
ar.k6 and ar.k7 restored as if we're in userland.

Thus: restore ar.k6 and ar.k7 unconditionally at the cost of losing
a valuable invariant. Both registers now hold the extend of the
usable portion of the kernel stack at any interrupt nesting, which
when in userland mean the bottom and the top of the kstack.
2003-05-24 20:51:55 +00:00
Ruslan Ermilov
734ac3b543 mdoc(7) fixes.
Approved by:	re (blanket)
2003-05-24 19:53:08 +00:00
Peter Wemm
ed8c5dcdc0 libstdc++.so breaks on amd64 due to bogons in our build, so prevent the
shared library being built for amd64.  The problem is that libstdc++.so
is produced with 'cc -shared'.  This has an internal -lgcc, which is
not PIC.  libstdc++.so uses exceptions and the dwarf2 unwinder, which
are in libgcc.a.  As a result, non-PIC code gets pulled into libstdc++.so.
This is fatal on amd64 when certain relocation types cannot be used in
PIC mode.  The official FSF solution to this is to have libgcc.so with
internal ELF symbol versioning to solve the ABI problem, but I dont want
to fight that battle yet.  I tried making libgcc_pic.a (which worked
fine), but thats not something for the 11th hour before a release.

Approved by:  re (amd64 "safe" stuff)
2003-05-24 19:38:18 +00:00
Peter Wemm
14682d7e53 no libc_r on amd64 yet -> no pppctl.
Approved by:	re (safe amd64 changes)
2003-05-24 19:23:05 +00:00
Hiroki Sato
2f98a50b76 Merge some entries from maho's USB device compatibility list.
Approved by:	re (bmah)
Obtained from:	http://people.FreeBSD.org/~maho/USB/
2003-05-24 18:50:20 +00:00
Hiten Pandya
b8a83c23ca Get usb(4) manual page closer to reality:
- update ``struct usb_device_info''
	- add information about new fields in about struct
	- document USB_EVENT_IS_ATTACH() and USB_EVENT_IS_DETACH()
	- update URL of the USB.ORG developer documentation

PR:	     docs/41580 (original patch)
Reviewed by: n_hibma
Approved by: des (mentor), re (bmah)
2003-05-24 18:28:18 +00:00
Peter Wemm
3ebd9b48ce Stop profiled libc from exploding, matching gcc's generated code.
Approved by: re (amd64/* blanket)
2003-05-24 18:24:03 +00:00
Hiten Pandya
1012d9d76c Bring vnode(9) man page to its senses:
- remove '-*- nroff -*-'
	- bump the date

	- nuke outdated ``struct vnode''
	  (it is just better to lookup the struct in the header)

	- nuke ``enum vtype'' and related junk
	- add a one line about ``struct vnode''
	- use .Va instead of .Dv for vnode struct fields

Approved by: des (mentor), re (bmah)
Reviewed by: arch@, mentor
2003-05-24 18:19:11 +00:00
Peter Wemm
b82eca913d Do not exclude amd64 from rtld-elf builds.
Approved by:  re  (safe amd64 support commits)
2003-05-24 17:38:45 +00:00
Peter Wemm
9783a12b34 Initial pass at supporting shared libraries on amd64. There are still
a few missing relocation types in amd64/reloc.c, but I have not found
any of them in use yet. :-)

Approved by:  re (amd64/* blanket)
2003-05-24 17:37:51 +00:00
Peter Wemm
b3aa27a531 Repair PIC mode. It seems I was a bit too excited about the
implications of native PC relative addressing.
2003-05-24 17:35:23 +00:00
Daniel Eischen
1cb570c531 Change low-level locking a bit so that we can tell if
a lock is being waitied on.

Fix a races in join and cancellation.

When trying to wait on a CV and the library is not yet
threaded, make it threaded so that waiting actually works.

When trying to nanosleep() and we're not threaded, just
call the system call nanosleep instead of adding the thread
to the wait queue.

Clean up adding/removing new threads to the "all threads queue",
assigning them unique ids, and tracking how many active threads
there are.  Do it all when the thread is added to the scheduling
queue instead of making pthread_create() know how to do it.

Fix a race where a thread could be marked for signal delivery
but it could be exited before we actually add the signal to it.

Other minor cleanups and bug fixes.

Submitted by:	davidxu
Approved by:	re@ (blanket for libpthread)
2003-05-24 02:29:25 +00:00
Mike Makonnen
a224a3919d Lock the cond queue (condition variables):
Access to the thread's flags and state is protected by
_thread_critical_enter/exit(). When a thread is signaled with a condition
its state must be protected by locking it and disabling
signals before it is taken of the waiters' queue.

Move the implementation of pthread_cond_signal() and pthread_cond_broadcast()
into one function, cond_signal(). Its behaviour is determined by the
last argument, int broadcast. If this is set to 1 it will remove all
waiters, otherwise it will wake up only the first waiter thread.

Remove an extraneous call to pthread_testcancel().

Approved by:	re/blanket libthr
2003-05-24 01:02:16 +00:00