diff options
Diffstat (limited to 'boot')
-rw-r--r-- | boot/Makefile | 5 | ||||
-rw-r--r-- | boot/boot.c | 49 | ||||
-rw-r--r-- | boot/ux.c | 14 |
3 files changed, 39 insertions, 29 deletions
diff --git a/boot/Makefile b/boot/Makefile index b7a835d0..0d883b06 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -27,7 +27,8 @@ OBJS = boot.o $(COMMON-OBJS) UX-OBJS = mach-crt0.o uxboot.o sigvec.o syscall.o ux.o $(COMMON-OBJS) target = boot io-MIGSFLAGS=-DREPLY_PORTS -HURDLIBS=store shouldbeinlibc threads +HURDLIBS = store shouldbeinlibc +OTHERLIBS = -lpthread include ../Makeconf @@ -45,7 +46,7 @@ ourdevice.defs: device.defs uxboot.o: boot.c $(COMPILE.c) -DUX $< -o $@ -uxboot.0: $(UX-OBJS) ../libthreads/libthreads.a +uxboot.0: $(UX-OBJS) $(LINK.o) -o $@ -static -nostartfiles -Wl,-T -Wl,$(srcdir)/frank1.ld $^ uxboot.1: frankemul.ld uxboot.0 $(LD) -o $@ -T $^ diff --git a/boot/boot.c b/boot/boot.c index 2b143844..fbbced77 100644 --- a/boot/boot.c +++ b/boot/boot.c @@ -30,11 +30,12 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <cthreads.h> +#include <pthread.h> #include <fcntl.h> #include <elf.h> #include <mach/mig_support.h> #include <mach/default_pager.h> +#include <mach/machine/vm_param.h> /* For VM_XXX_ADDRESS */ #include <argp.h> #include <hurd/store.h> #include <sys/mman.h> @@ -116,8 +117,8 @@ auth_t authserver; struct store *root_store; -spin_lock_t queuelock = SPIN_LOCK_INITIALIZER; -spin_lock_t readlock = SPIN_LOCK_INITIALIZER; +pthread_spinlock_t queuelock = PTHREAD_SPINLOCK_INITIALIZER; +pthread_spinlock_t readlock = PTHREAD_SPINLOCK_INITIALIZER; mach_port_t php_child_name, psmdp_child_name, taskname; @@ -291,7 +292,7 @@ load_image (task_t t, void read_reply (); -void msg_thread (); +void * msg_thread (void *); /* Callbacks for boot_script.c; see boot_script.h. */ @@ -528,6 +529,7 @@ main (int argc, char **argv, char **envp) mach_port_t foo; char *buf = 0; int i, len; + pthread_t pthread_id; char *root_store_name; const struct argp_child kids[] = { { &store_argp }, { 0 }}; struct argp argp = { options, parse_opt, args_doc, doc, kids }; @@ -738,7 +740,14 @@ main (int argc, char **argv, char **envp) mach_port_deallocate (mach_task_self (), pseudo_master_device_port); - cthread_detach (cthread_fork ((cthread_fn_t) msg_thread, (any_t) 0)); + err = pthread_create (&pthread_id, NULL, msg_thread, NULL); + if (!err) + pthread_detach (pthread_id); + else + { + errno = err; + perror ("pthread_create"); + } for (;;) { @@ -754,8 +763,8 @@ main (int argc, char **argv, char **envp) /* mach_msg_server (request_server, __vm_page_size * 2, receive_set); */ } -void -msg_thread() +void * +msg_thread (void *arg) { while (1) mach_msg_server (request_server, 0, receive_set); @@ -791,7 +800,7 @@ queue_read (enum read_type type, if (!qr) return D_NO_MEMORY; - spin_lock (&queuelock); + pthread_spin_lock (&queuelock); qr->type = type; qr->reply_port = reply_port; @@ -803,7 +812,7 @@ queue_read (enum read_type type, else qrhead = qrtail = qr; - spin_unlock (&queuelock); + pthread_spin_unlock (&queuelock); return D_SUCCESS; } @@ -824,7 +833,7 @@ read_reply () either we get the lock ourselves or that whoever currently holds the lock will service this read when he unlocks it. */ should_read = 1; - if (! spin_try_lock (&readlock)) + if (pthread_spin_trylock (&readlock)) return; /* Since we're committed to servicing the read, no one else need do so. */ @@ -833,16 +842,16 @@ read_reply () ioctl (0, FIONREAD, &avail); if (!avail) { - spin_unlock (&readlock); + pthread_spin_unlock (&readlock); return; } - spin_lock (&queuelock); + pthread_spin_lock (&queuelock); if (!qrhead) { - spin_unlock (&queuelock); - spin_unlock (&readlock); + pthread_spin_unlock (&queuelock); + pthread_spin_unlock (&readlock); return; } @@ -851,7 +860,7 @@ read_reply () if (qr == qrtail) qrtail = 0; - spin_unlock (&queuelock); + pthread_spin_unlock (&queuelock); if (qr->type == DEV_READ) buf = mmap (0, qr->amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); @@ -859,7 +868,7 @@ read_reply () buf = alloca (qr->amount); amtread = read (0, buf, qr->amount); - spin_unlock (&readlock); + pthread_spin_unlock (&readlock); switch (qr->type) { @@ -897,7 +906,7 @@ read_reply () static void unlock_readlock () { - spin_unlock (&readlock); + pthread_spin_unlock (&readlock); while (should_read) read_reply (); } @@ -1131,7 +1140,7 @@ ds_device_read (device_t device, } #endif - spin_lock (&readlock); + pthread_spin_lock (&readlock); ioctl (0, FIONREAD, &avail); if (avail) { @@ -1186,7 +1195,7 @@ ds_device_read_inband (device_t device, } #endif - spin_lock (&readlock); + pthread_spin_lock (&readlock); ioctl (0, FIONREAD, &avail); if (avail) { @@ -1459,7 +1468,7 @@ S_io_read (mach_port_t object, } #endif - spin_lock (&readlock); + pthread_spin_lock (&readlock); ioctl (0, FIONREAD, &avail); if (avail) { @@ -24,7 +24,7 @@ #include <stdlib.h> #include <stdarg.h> #include <string.h> -#include <cthreads.h> +#include <pthread.h> #include "ux.h" @@ -54,14 +54,14 @@ struct free_reply_port struct free_reply_port *next; }; static struct free_reply_port *free_reply_ports = NULL; -static spin_lock_t free_reply_ports_lock = SPIN_LOCK_INITIALIZER; +static pthread_spinlock_t free_reply_ports_lock = PTHREAD_SPINLOCK_INITIALIZER; mach_port_t __mig_get_reply_port () { - spin_lock (&free_reply_ports_lock); + pthread_spin_lock (&free_reply_ports_lock); if (free_reply_ports == NULL) { - spin_unlock (&free_reply_ports_lock); + pthread_spin_unlock (&free_reply_ports_lock); return __mach_reply_port (); } else @@ -69,7 +69,7 @@ mach_port_t __mig_get_reply_port () struct free_reply_port *frp = free_reply_ports; mach_port_t reply_port = frp->port; free_reply_ports = free_reply_ports->next; - spin_unlock (&free_reply_ports_lock); + pthread_spin_unlock (&free_reply_ports_lock); free (frp); return reply_port; } @@ -82,10 +82,10 @@ void __mig_put_reply_port (mach_port_t port) { struct free_reply_port *frp = malloc (sizeof (struct free_reply_port)); frp->port = port; - spin_lock (&free_reply_ports_lock); + pthread_spin_lock (&free_reply_ports_lock); frp->next = free_reply_ports; free_reply_ports = frp; - spin_unlock (&free_reply_ports_lock); + pthread_spin_unlock (&free_reply_ports_lock); } void mig_put_reply_port (mach_port_t port) { |