diff options
Diffstat (limited to 'boot/boot.c')
-rw-r--r-- | boot/boot.c | 49 |
1 files changed, 29 insertions, 20 deletions
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) { |