summaryrefslogtreecommitdiff
path: root/proc
diff options
context:
space:
mode:
Diffstat (limited to 'proc')
-rw-r--r--proc/Makefile3
-rw-r--r--proc/info.c4
-rw-r--r--proc/main.c6
-rw-r--r--proc/mgt.c8
-rw-r--r--proc/msg.c27
-rw-r--r--proc/proc.h6
-rw-r--r--proc/stubs.c18
-rw-r--r--proc/wait.c6
8 files changed, 51 insertions, 27 deletions
diff --git a/proc/Makefile b/proc/Makefile
index d54166d2..2eed13c1 100644
--- a/proc/Makefile
+++ b/proc/Makefile
@@ -31,7 +31,8 @@ MIGSFLAGS="-DPROCESS_INTRAN=pstruct_t reqport_find (process_t)" \
MIGSTUBS = processServer.o notifyServer.o \
ourmsgUser.o proc_excUser.o proc_excServer.o
OBJS = $(SRCS:.c=.o) $(MIGSTUBS)
-HURDLIBS=threads ihash ports shouldbeinlibc
+HURDLIBS = ihash ports shouldbeinlibc
+OTHERLIBS = -lpthread
include ../Makeconf
diff --git a/proc/info.c b/proc/info.c
index f35ad166..40f9d210 100644
--- a/proc/info.c
+++ b/proc/info.c
@@ -467,7 +467,7 @@ S_proc_getprocinfo (struct proc *callerp,
/* Release GLOBAL_LOCK around time consuming bits, and more importatantly,
potential calls to P's msgport, which can block. */
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
if (*flags & PI_FETCH_TASKINFO)
{
@@ -618,7 +618,7 @@ S_proc_getprocinfo (struct proc *callerp,
*waits_len = waits_used;
/* Reacquire GLOBAL_LOCK to make the central locking code happy. */
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
return err;
}
diff --git a/proc/main.c b/proc/main.c
index f2cdfdf5..494169e7 100644
--- a/proc/main.c
+++ b/proc/main.c
@@ -42,16 +42,16 @@ message_demuxer (mach_msg_header_t *inp,
extern int proc_exc_server (mach_msg_header_t *, mach_msg_header_t *);
int status;
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
status = (process_server (inp, outp)
|| notify_server (inp, outp)
|| ports_interrupt_server (inp, outp)
|| proc_exc_server (inp, outp));
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
return status;
}
-struct mutex global_lock = MUTEX_INITIALIZER;
+pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER;
int
main (int argc, char **argv, char **envp)
diff --git a/proc/mgt.c b/proc/mgt.c
index 1180c700..7af9c1aa 100644
--- a/proc/mgt.c
+++ b/proc/mgt.c
@@ -106,7 +106,7 @@ S_proc_reauthenticate (struct proc *p, mach_port_t rendport)
naux_gids = sizeof (agbuf) / sizeof (uid_t);
/* Release the global lock while blocking on the auth server and client. */
- mutex_unlock (&global_lock);
+ pthread_mutex_unlock (&global_lock);
err = auth_server_authenticate (authserver,
rendport, MACH_MSG_TYPE_COPY_SEND,
MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND,
@@ -114,7 +114,7 @@ S_proc_reauthenticate (struct proc *p, mach_port_t rendport)
&aux_uids, &naux_uids,
&gen_gids, &ngen_gids,
&aux_gids, &naux_gids);
- mutex_lock (&global_lock);
+ pthread_mutex_lock (&global_lock);
if (err)
return err;
@@ -565,7 +565,7 @@ allocate_proc (task_t task)
p->p_task = task;
p->p_msgport = MACH_PORT_NULL;
- condition_init (&p->p_wakeup);
+ pthread_cond_init (&p->p_wakeup, NULL);
return p;
}
@@ -756,7 +756,7 @@ process_has_exited (struct proc *p)
/* If an operation is in progress for this process, cause it
to wakeup and return now. */
if (p->p_waiting || p->p_msgportwait)
- condition_broadcast (&p->p_wakeup);
+ pthread_cond_broadcast (&p->p_wakeup);
p->p_dead = 1;
diff --git a/proc/msg.c b/proc/msg.c
index ff1dbc54..a6eca218 100644
--- a/proc/msg.c
+++ b/proc/msg.c
@@ -21,6 +21,7 @@
#include <hurd/startup.h>
#include <assert.h>
#include <stdlib.h>
+#include <stdio.h>
/* Check to see if process P is blocked trying to get the message
port of process AVAILP; if so, return its call. */
@@ -29,18 +30,18 @@ check_message_return (struct proc *p, void *availpaddr)
{
if (p->p_msgportwait)
{
- condition_broadcast (&p->p_wakeup);
+ pthread_cond_broadcast (&p->p_wakeup);
p->p_msgportwait = 0;
}
}
/* Register ourselves with init. */
-static any_t
-tickle_init (any_t initport)
+static void *
+tickle_init (void *initport)
{
startup_essential_task ((mach_port_t) initport, mach_task_self (),
MACH_PORT_NULL, "proc", master_host_port);
- return 0;
+ return NULL;
}
error_t
@@ -63,9 +64,21 @@ S_proc_setmsgport (struct proc *p,
p->p_checkmsghangs = 0;
if (p == startup_proc)
+ {
/* Init is single threaded, so we can't delay our reply for
the essential task RPC; spawn a thread to do it. */
- cthread_detach (cthread_fork (tickle_init, (any_t) msgport));
+ pthread_t thread;
+ error_t err;
+ err = pthread_create (&thread, NULL, tickle_init,
+ (void*) (uintptr_t) msgport);
+ if (!err)
+ pthread_detach (thread);
+ else
+ {
+ errno = err;
+ perror ("pthread_create");
+ }
+ }
return 0;
}
@@ -77,7 +90,7 @@ check_message_dying (struct proc *p, struct proc *dyingp)
{
if (p->p_msgportwait)
{
- condition_broadcast (&p->p_wakeup);
+ pthread_cond_broadcast (&p->p_wakeup);
p->p_msgportwait = 0;
}
}
@@ -128,7 +141,7 @@ restart:
{
callerp->p_msgportwait = 1;
p->p_checkmsghangs = 1;
- cancel = hurd_condition_wait (&callerp->p_wakeup, &global_lock);
+ cancel = pthread_hurd_cond_wait_np (&callerp->p_wakeup, &global_lock);
if (callerp->p_dead)
return EOPNOTSUPP;
if (cancel)
diff --git a/proc/proc.h b/proc/proc.h
index 7943e0be..247795dc 100644
--- a/proc/proc.h
+++ b/proc/proc.h
@@ -26,7 +26,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <sys/mman.h>
#include <hurd/ports.h>
#include <hurd/ihash.h>
-#include <cthreads.h>
+#include <pthread.h>
struct proc
{
@@ -60,7 +60,7 @@ struct proc
/* Communication */
mach_port_t p_msgport; /* send right */
- struct condition p_wakeup;
+ pthread_cond_t p_wakeup;
/* Miscellaneous information */
vm_address_t p_argv, p_envp;
@@ -145,7 +145,7 @@ mach_port_t master_device_port;
mach_port_t generic_port; /* messages not related to a specific proc */
-struct mutex global_lock;
+pthread_mutex_t global_lock;
static inline void __attribute__ ((unused))
process_drop (struct proc *p)
diff --git a/proc/stubs.c b/proc/stubs.c
index de3a9b11..096e55ef 100644
--- a/proc/stubs.c
+++ b/proc/stubs.c
@@ -15,12 +15,13 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-#include <cthreads.h>
+#include <pthread.h>
#include <stdlib.h>
#include <hurd/hurd_types.h>
#include <mach/message.h>
#include <string.h>
#include <assert.h>
+#include <stdio.h>
#include "proc.h"
@@ -41,8 +42,8 @@ struct msg_sig_post_request
/* Send the Mach message indicated by msg_spec. call cthread_exit
when it has been delivered. */
-static any_t
-blocking_message_send (any_t arg)
+static void *
+blocking_message_send (void *arg)
{
struct msg_sig_post_request *const req = arg;
error_t err;
@@ -146,8 +147,17 @@ send_signal (mach_port_t msgport,
struct msg_sig_post_request *copy = malloc (sizeof *copy);
if (copy)
{
+ pthread_t thread;
+ error_t err;
memcpy (copy, &message, sizeof message);
- cthread_detach (cthread_fork (blocking_message_send, copy));
+ err = pthread_create (&thread, NULL, blocking_message_send, copy);
+ if (!err)
+ pthread_detach (thread);
+ else
+ {
+ errno = err;
+ perror ("pthread_create");
+ }
}
break;
}
diff --git a/proc/wait.c b/proc/wait.c
index 6fc94e83..824e6672 100644
--- a/proc/wait.c
+++ b/proc/wait.c
@@ -154,7 +154,7 @@ alert_parent (struct proc *p)
if (p->p_parent->p_waiting)
{
- condition_broadcast (&p->p_parent->p_wakeup);
+ pthread_cond_broadcast (&p->p_parent->p_wakeup);
p->p_parent->p_waiting = 0;
}
}
@@ -228,7 +228,7 @@ S_proc_wait (struct proc *p,
return EWOULDBLOCK;
p->p_waiting = 1;
- cancel = hurd_condition_wait (&p->p_wakeup, &global_lock);
+ cancel = pthread_hurd_cond_wait_np (&p->p_wakeup, &global_lock);
if (p->p_dead)
return EOPNOTSUPP;
if (cancel)
@@ -252,7 +252,7 @@ S_proc_mark_stop (struct proc *p,
if (p->p_parent->p_waiting)
{
- condition_broadcast (&p->p_parent->p_wakeup);
+ pthread_cond_broadcast (&p->p_parent->p_wakeup);
p->p_parent->p_waiting = 0;
}