summaryrefslogtreecommitdiff
path: root/mach-defpager
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2012-09-04 00:33:09 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2012-11-27 22:58:15 +0100
commit1de0643c9218db536f5b2e294bbfa653c77438e4 (patch)
treef944e1b023cf0353ca559d22e1f7b701bac04c97 /mach-defpager
parent7648503cd894549874ff13f7ed94a4708cf50f0d (diff)
Switch from cthreads to pthreads
Makefiles, headers, types, macros and function calls are renamed where appropriate. Most of this work was done by Barry deFreese and Thomas DiModica. * auth/Makefile: Switch from cthreads to pthreads. * auth/auth.c: Likewise. * boot/Makefile: Likewise. * boot/boot.c: Likewise. * boot/ux.c: Likewise. * console-client/Makefile: Likewise. * console-client/console.c: Likewise. * console-client/driver.c: Likewise. * console-client/driver.h: Likewise. * console-client/generic-speaker.c: Likewise. * console-client/kbd-repeat.c: Likewise. * console-client/ncursesw.c: Likewise. * console-client/pc-kbd.c: Likewise. * console-client/pc-mouse.c: Likewise. * console-client/timer.c: Likewise. * console-client/trans.c: Likewise. * console-client/vga.c: Likewise. * console/Makefile: Likewise. * console/console.c: Likewise. * console/display.c: Likewise. * console/input.c: Likewise. * console/pager.c: Likewise. * defpager/backing.c: Likewise. * exec/Makefile: Likewise. * exec/exec.c: Likewise. * exec/hashexec.c: Likewise. * exec/priv.h: Likewise. * ext2fs/Makefile: Likewise. * ext2fs/balloc.c: Likewise. * ext2fs/dir.c: Likewise. * ext2fs/ext2fs.c: Likewise. * ext2fs/ext2fs.h: Likewise. * ext2fs/ialloc.c: Likewise. * ext2fs/inode.c: Likewise. * ext2fs/msg.c: Likewise. * ext2fs/pager.c: Likewise. * ext2fs/pokel.c: Likewise. * ext2fs/storeinfo.c: Likewise. * ext2fs/truncate.c: Likewise. * fatfs/Makefile: Likewise. * fatfs/dir.c: Likewise. * fatfs/fat.c: Likewise. * fatfs/fatfs.h: Likewise. * fatfs/inode.c: Likewise. * fatfs/main.c: Likewise. * fatfs/pager.c: Likewise. * fatfs/virt-inode.c: Likewise. * ftpfs/Makefile: Likewise. * ftpfs/ccache.c: Likewise. * ftpfs/ccache.h: Likewise. * ftpfs/conn.c: Likewise. * ftpfs/dir.c: Likewise. * ftpfs/fs.c: Likewise. * ftpfs/ftpfs.c: Likewise. * ftpfs/ftpfs.h: Likewise. * ftpfs/ncache.c: Likewise. * ftpfs/netfs.c: Likewise. * ftpfs/node.c: Likewise. * hostmux/Makefile: Likewise. * hostmux/hostmux.h: Likewise. * hostmux/mux.c: Likewise. * hostmux/node.c: Likewise. * hostmux/stubs.c: Likewise. * hurd/shared.h: Likewise. * isofs/Makefile: Likewise. * isofs/inode.c: Likewise. * isofs/lookup.c: Likewise. * isofs/main.c: Likewise. * isofs/pager.c: Likewise. * libcons/Makefile: Likewise. * libcons/cons-switch.c: Likewise. * libcons/cons.h: Likewise. * libcons/dir-changed.c: Likewise. * libcons/file-changed.c: Likewise. * libcons/init-init.c: Likewise. * libcons/vcons-close.c: Likewise. * libcons/vcons-input.c: Likewise. * libcons/vcons-move-mouse.c: Likewise. * libcons/vcons-open.c: Likewise. * libcons/vcons-scrollback.c: Likewise. * libdiskfs/Makefile: Likewise. * libdiskfs/boot-start.c: Likewise. * libdiskfs/dead-name.c: Likewise. * libdiskfs/dir-chg.c: Likewise. * libdiskfs/dir-link.c: Likewise. * libdiskfs/dir-lookup.c: Likewise. * libdiskfs/dir-mkdir.c: Likewise. * libdiskfs/dir-mkfile.c: Likewise. * libdiskfs/dir-readdir.c: Likewise. * libdiskfs/dir-rename.c: Likewise. * libdiskfs/dir-renamed.c: Likewise. * libdiskfs/dir-rmdir.c: Likewise. * libdiskfs/dir-unlink.c: Likewise. * libdiskfs/disk-pager.c: Likewise. * libdiskfs/diskfs-pager.h: Likewise. * libdiskfs/diskfs.h: Likewise. * libdiskfs/file-access.c: Likewise. * libdiskfs/file-chg.c: Likewise. * libdiskfs/file-exec.c: Likewise. * libdiskfs/file-get-fs-opts.c: Likewise. * libdiskfs/file-get-trans.c: Likewise. * libdiskfs/file-get-transcntl.c: Likewise. * libdiskfs/file-getcontrol.c: Likewise. * libdiskfs/file-getfh.c: Likewise. * libdiskfs/file-lock-stat.c: Likewise. * libdiskfs/file-lock.c: Likewise. * libdiskfs/file-reparent.c: Likewise. * libdiskfs/file-set-trans.c: Likewise. * libdiskfs/file-sync.c: Likewise. * libdiskfs/file-syncfs.c: Likewise. * libdiskfs/fsys-getroot.c: Likewise. * libdiskfs/fsys-options.c: Likewise. * libdiskfs/fsys-syncfs.c: Likewise. * libdiskfs/ifsock.c: Likewise. * libdiskfs/init-first.c: Likewise. * libdiskfs/init-init.c: Likewise. * libdiskfs/init-startup.c: Likewise. * libdiskfs/io-duplicate.c: Likewise. * libdiskfs/io-get-conch.c: Likewise. * libdiskfs/io-identity.c: Likewise. * libdiskfs/io-map-cntl.c: Likewise. * libdiskfs/io-map.c: Likewise. * libdiskfs/io-modes-get.c: Likewise. * libdiskfs/io-modes-off.c: Likewise. * libdiskfs/io-modes-on.c: Likewise. * libdiskfs/io-modes-set.c: Likewise. * libdiskfs/io-owner-get.c: Likewise. * libdiskfs/io-owner-mod.c: Likewise. * libdiskfs/io-prenotify.c: Likewise. * libdiskfs/io-read.c: Likewise. * libdiskfs/io-readable.c: Likewise. * libdiskfs/io-reauthenticate.c: Likewise. * libdiskfs/io-rel-conch.c: Likewise. * libdiskfs/io-restrict-auth.c: Likewise. * libdiskfs/io-revoke.c: Likewise. * libdiskfs/io-seek.c: Likewise. * libdiskfs/io-sigio.c: Likewise. * libdiskfs/io-stat.c: Likewise. * libdiskfs/io-write.c: Likewise. * libdiskfs/lookup.c: Likewise. * libdiskfs/name-cache.c: Likewise. * libdiskfs/node-drop.c: Likewise. * libdiskfs/node-make.c: Likewise. * libdiskfs/node-nput.c: Likewise. * libdiskfs/node-nputl.c: Likewise. * libdiskfs/node-nref.c: Likewise. * libdiskfs/node-nrefl.c: Likewise. * libdiskfs/node-nrele.c: Likewise. * libdiskfs/node-nrelel.c: Likewise. * libdiskfs/peropen-rele.c: Likewise. * libdiskfs/priv.h: Likewise. * libdiskfs/shutdown.c: Likewise. * libdiskfs/sync-interval.c: Likewise. * libfshelp/Makefile: Likewise. * libfshelp/fetch-root.c: Likewise. * libfshelp/fshelp.h: Likewise. * libfshelp/get-identity.c: Likewise. * libfshelp/lock-acquire.c: Likewise. * libfshelp/lock-init.c: Likewise. * libfshelp/locks.h: Likewise. * libfshelp/set-active.c: Likewise. * libfshelp/trans.h: Likewise. * libfshelp/transbox-init.c: Likewise. * libiohelp/Makefile: Likewise. * libiohelp/get_conch.c: Likewise. * libiohelp/handle_io_release_conch.c: Likewise. * libiohelp/initialize_conch.c: Likewise. * libiohelp/iohelp.h: Likewise. * libiohelp/verify_user_conch.c: Likewise. * libnetfs/Makefile: Likewise. * libnetfs/dir-lookup.c: Likewise. * libnetfs/dir-mkdir.c: Likewise. * libnetfs/dir-mkfile.c: Likewise. * libnetfs/dir-readdir.c: Likewise. * libnetfs/dir-rmdir.c: Likewise. * libnetfs/dir-unlink.c: Likewise. * libnetfs/drop-node.c: Likewise. * libnetfs/file-chauthor.c: Likewise. * libnetfs/file-check-access.c: Likewise. * libnetfs/file-chflags.c: Likewise. * libnetfs/file-chmod.c: Likewise. * libnetfs/file-chown.c: Likewise. * libnetfs/file-exec.c: Likewise. * libnetfs/file-get-storage-info.c: Likewise. * libnetfs/file-get-translator.c: Likewise. * libnetfs/file-lock-stat.c: Likewise. * libnetfs/file-lock.c: Likewise. * libnetfs/file-reparent.c: Likewise. * libnetfs/file-set-size.c: Likewise. * libnetfs/file-set-translator.c: Likewise. * libnetfs/file-statfs.c: Likewise. * libnetfs/file-sync.c: Likewise. * libnetfs/file-syncfs.c: Likewise. * libnetfs/file-utimes.c: Likewise. * libnetfs/fsys-getroot.c: Likewise. * libnetfs/fsys-set-options.c: Likewise. * libnetfs/init-init.c: Likewise. * libnetfs/io-clear-some-openmodes.c: Likewise. * libnetfs/io-duplicate.c: Likewise. * libnetfs/io-get-openmodes.c: Likewise. * libnetfs/io-get-owner.c: Likewise. * libnetfs/io-identity.c: Likewise. * libnetfs/io-mod-owner.c: Likewise. * libnetfs/io-read.c: Likewise. * libnetfs/io-readable.c: Likewise. * libnetfs/io-reauthenticate.c: Likewise. * libnetfs/io-restrict-auth.c: Likewise. * libnetfs/io-revoke.c: Likewise. * libnetfs/io-seek.c: Likewise. * libnetfs/io-set-all-openmodes.c: Likewise. * libnetfs/io-set-some-openmodes.c: Likewise. * libnetfs/io-stat.c: Likewise. * libnetfs/io-write.c: Likewise. * libnetfs/make-node.c: Likewise. * libnetfs/netfs.h: Likewise. * libnetfs/nput.c: Likewise. * libnetfs/nref.c: Likewise. * libnetfs/nrele.c: Likewise. * libnetfs/release-peropen.c: Likewise. * libnetfs/shutdown.c: Likewise. * libpager/Makefile: Likewise. * libpager/chg-compl.c: Likewise. * libpager/clean.c: Likewise. * libpager/data-request.c: Likewise. * libpager/data-return.c: Likewise. * libpager/data-unlock.c: Likewise. * libpager/inhibit-term.c: Likewise. * libpager/lock-completed.c: Likewise. * libpager/lock-object.c: Likewise. * libpager/mark-error.c: Likewise. * libpager/no-senders.c: Likewise. * libpager/object-init.c: Likewise. * libpager/object-terminate.c: Likewise. * libpager/offer-page.c: Likewise. * libpager/pager-attr.c: Likewise. * libpager/pager-create.c: Likewise. * libpager/pager-shutdown.c: Likewise. * libpager/priv.h: Likewise. * libpager/seqnos.c: Likewise. * libpipe/Makefile: Likewise. * libpipe/pipe.c: Likewise. * libpipe/pipe.h: Likewise. * libports/Makefile: Likewise. * libports/begin-rpc.c: Likewise. * libports/bucket-iterate.c: Likewise. * libports/claim-right.c: Likewise. * libports/class-iterate.c: Likewise. * libports/complete-deallocate.c: Likewise. * libports/count-bucket.c: Likewise. * libports/count-class.c: Likewise. * libports/create-bucket.c: Likewise. * libports/create-internal.c: Likewise. * libports/destroy-right.c: Likewise. * libports/enable-bucket.c: Likewise. * libports/enable-class.c: Likewise. * libports/end-rpc.c: Likewise. * libports/get-right.c: Likewise. * libports/import-port.c: Likewise. * libports/inhibit-all-rpcs.c: Likewise. * libports/inhibit-bucket-rpcs.c: Likewise. * libports/inhibit-class-rpcs.c: Likewise. * libports/inhibit-port-rpcs.c: Likewise. * libports/init.c: Likewise. * libports/interrupt-notified-rpcs.c: Likewise. * libports/interrupt-on-notify.c: Likewise. * libports/interrupt-operation.c: Likewise. * libports/interrupt-rpcs.c: Likewise. * libports/interrupted.c: Likewise. * libports/lookup-port.c: Likewise. * libports/manage-multithread.c: Likewise. * libports/no-senders.c: Likewise. * libports/port-deref-weak.c: Likewise. * libports/port-deref.c: Likewise. * libports/port-ref-weak.c: Likewise. * libports/port-ref.c: Likewise. * libports/ports.h: Likewise. * libports/reallocate-from-external.c: Likewise. * libports/reallocate-port.c: Likewise. * libports/resume-all-rpcs.c: Likewise. * libports/resume-bucket-rpcs.c: Likewise. * libports/resume-class-rpcs.c: Likewise. * libports/resume-port-rpcs.c: Likewise. * libports/stubs.c: Likewise. * libports/transfer-right.c: Likewise. * libstore/Makefile: Likewise. * libstore/gunzip.c: Likewise. * libstore/part.c: Likewise. * libstore/unzipstore.c: Likewise. * libthreads/Makefile: Likewise. * libtreefs/dir-lookup.c: Likewise. * libtreefs/fsys-getroot.c: Likewise. * libtreefs/fsys-hooks.c: Likewise. * libtreefs/fsys.c: Likewise. * libtreefs/trans-help.c: Likewise. * libtreefs/trans-start.c: Likewise. * libtreefs/treefs.h: Likewise. * libtrivfs/cntl-create.c: Likewise. * libtrivfs/dyn-classes.c: Likewise. * libtrivfs/io-reauthenticate.c: Likewise. * libtrivfs/io-restrict-auth.c: Likewise. * libtrivfs/protid-clean.c: Likewise. * libtrivfs/protid-dup.c: Likewise. * libtrivfs/trivfs.h: Likewise. * mach-defpager/Makefile: Likewise. * mach-defpager/default_pager.c: Likewise. * mach-defpager/kalloc.c: Likewise. * mach-defpager/main.c: Likewise. * nfs/Makefile: Likewise. * nfs/cache.c: Likewise. * nfs/main.c: Likewise. * nfs/mount.c: Likewise. * nfs/name-cache.c: Likewise. * nfs/nfs.h: Likewise. * nfs/ops.c: Likewise. * nfs/rpc.c: Likewise. * nfsd/Makefile: Likewise. * nfsd/cache.c: Likewise. * nfsd/loop.c: Likewise. * nfsd/main.c: Likewise. * nfsd/nfsd.h: Likewise. * pfinet/Makefile: Likewise. * pfinet/ethernet.c: Likewise. * pfinet/glue-include/asm/spinlock.h: Likewise. * pfinet/glue-include/linux/interrupt.h: Likewise. * pfinet/glue-include/linux/sched.h: Likewise. * pfinet/glue-include/linux/timer.h: Likewise. * pfinet/glue-include/linux/wait.h: Likewise. * pfinet/iioctl-ops.c: Likewise. * pfinet/io-ops.c: Likewise. * pfinet/kmem_cache.c: Likewise. * pfinet/main.c: Likewise. * pfinet/options.c: Likewise. * pfinet/pfinet-ops.c: Likewise. * pfinet/pfinet.h: Likewise. * pfinet/sched.c: Likewise. * pfinet/socket-ops.c: Likewise. * pfinet/socket.c: Likewise. * pfinet/timer-emul.c: Likewise. * pfinet/tunnel.c: Likewise. * pflocal/Makefile: Likewise. * pflocal/connq.c: Likewise. * pflocal/io.c: Likewise. * pflocal/sock.c: Likewise. * pflocal/sock.h: Likewise. * pflocal/socket.c: Likewise. * pflocal/sserver.c: Likewise. * proc/Makefile: Likewise. * proc/info.c: Likewise. * proc/main.c: Likewise. * proc/mgt.c: Likewise. * proc/msg.c: Likewise. * proc/proc.h: Likewise. * proc/stubs.c: Likewise. * proc/wait.c: Likewise. * storeio/Makefile: Likewise. * storeio/dev.c: Likewise. * storeio/dev.h: Likewise. * storeio/open.c: Likewise. * storeio/open.h: Likewise. * storeio/pager.c: Likewise. * storeio/storeio.c: Likewise. * term/Makefile: Likewise. * term/devio.c: Likewise. * term/hurdio.c: Likewise. * term/main.c: Likewise. * term/munge.c: Likewise. * term/ptyio.c: Likewise. * term/term.h: Likewise. * term/users.c: Likewise. * tmpfs/Makefile: Likewise. * tmpfs/dir.c: Likewise. * tmpfs/node.c: Likewise. * tmpfs/tmpfs.c: Likewise. * tmpfs/tmpfs.h: Likewise. * trans/Makefile: Likewise. * trans/fakeroot.c: Likewise. * trans/fifo.c: Likewise. * trans/hello-mt.c: Likewise. * trans/new-fifo.c: Likewise. * trans/streamio.c: Likewise. * ufs/Makefile: Likewise. * ufs/alloc.c: Likewise. * ufs/dir.c: Likewise. * ufs/hyper.c: Likewise. * ufs/inode.c: Likewise. * ufs/main.c: Likewise. * ufs/pager.c: Likewise. * ufs/pokeloc.c: Likewise. * ufs/sizes.c: Likewise. * ufs/ufs.h: Likewise. * usermux/Makefile: Likewise. * usermux/mux.c: Likewise. * usermux/node.c: Likewise. * usermux/usermux.h: Likewise. * utils/Makefile: Likewise. * utils/fakeauth.c: Likewise. * utils/rpctrace.c: Likewise.
Diffstat (limited to 'mach-defpager')
-rw-r--r--mach-defpager/Makefile2
-rw-r--r--mach-defpager/default_pager.c238
-rw-r--r--mach-defpager/kalloc.c32
-rw-r--r--mach-defpager/main.c10
4 files changed, 141 insertions, 141 deletions
diff --git a/mach-defpager/Makefile b/mach-defpager/Makefile
index b16aa80d..5a98d690 100644
--- a/mach-defpager/Makefile
+++ b/mach-defpager/Makefile
@@ -29,7 +29,7 @@ OBJS := $(SRCS:.c=.o) \
memory_object default_pager memory_object_default exc) \
default_pager_replyUser.o
-HURDLIBS:= threads
+OTHERLIBS:= -lpthread
LDFLAGS += -static
include ../Makeconf
diff --git a/mach-defpager/default_pager.c b/mach-defpager/default_pager.c
index b467cbce..ec875d4f 100644
--- a/mach-defpager/default_pager.c
+++ b/mach-defpager/default_pager.c
@@ -37,7 +37,7 @@
#include <mach/task_info.h>
#include <mach/default_pager_types.h>
-#include <cthreads.h>
+#include <pthread.h>
#include <device/device_types.h>
#include <device/device.h>
@@ -59,18 +59,24 @@
static char my_name[] = "(default pager):";
-static struct mutex printf_lock = MUTEX_INITIALIZER;
+static pthread_mutex_t printf_lock = PTHREAD_MUTEX_INITIALIZER;
#if 0
-#define dprintf(f, x...) \
- ({ mutex_lock (&printf_lock); printf (f , ##x); fflush (stdout); mutex_unlock (&printf_lock); })
+#define dprintf(f, x...) \
+ ({ pthread_mutex_lock (&printf_lock); \
+ printf (f , ##x); \
+ fflush (stdout); \
+ pthread_mutex_unlock (&printf_lock); })
#else
#define dprintf(f, x...)
#endif
#if 0
-#define ddprintf(f, x...) \
- ({ mutex_lock (&printf_lock); printf (f , ##x); fflush (stdout); mutex_unlock (&printf_lock); })
+#define ddprintf(f, x...) \
+ ({ pthread_mutex_lock (&printf_lock); \
+ printf (f , ##x); \
+ fflush (stdout); \
+ pthread_mutex_unlock (&printf_lock); })
#else
#define ddprintf(f, x...)
#endif
@@ -111,7 +117,7 @@ typedef unsigned int bm_entry_t;
* Controls allocation of blocks within paging area.
*/
struct part {
- struct mutex p_lock; /* for bitmap/free */
+ pthread_mutex_t p_lock; /* for bitmap/free */
vm_size_t total_size; /* total number of blocks */
vm_size_t free; /* number of blocks free */
unsigned int id; /* named lookup */
@@ -122,7 +128,7 @@ struct part {
typedef struct part *partition_t;
struct {
- struct mutex lock;
+ pthread_mutex_t lock;
int n_partitions;
partition_t *partition_list;/* array, for quick mapping */
} all_partitions; /* list of all such */
@@ -172,7 +178,7 @@ part_id(const char *name)
void
partition_init()
{
- mutex_init(&all_partitions.lock);
+ pthread_mutex_init(&all_partitions.lock, NULL);
all_partitions.n_partitions = 0;
}
@@ -187,7 +193,7 @@ new_partition (const char *name, struct file_direct *fdp,
int rc;
unsigned int id = part_id(name);
- mutex_lock(&all_partitions.lock);
+ pthread_mutex_lock(&all_partitions.lock);
{
unsigned int i;
for (i = 0; i < all_partitions.n_partitions; i++)
@@ -197,18 +203,18 @@ new_partition (const char *name, struct file_direct *fdp,
{
printf ("(default pager): Already paging to partition %s!\n",
name);
- mutex_unlock(&all_partitions.lock);
+ pthread_mutex_unlock(&all_partitions.lock);
return 0;
}
}
}
- mutex_unlock(&all_partitions.lock);
+ pthread_mutex_unlock(&all_partitions.lock);
size = atop(fdp->fd_size * fdp->fd_bsize);
bmsize = howmany(size, NB_BM) * sizeof(bm_entry_t);
part = (partition_t) kalloc(sizeof(struct part));
- mutex_init(&part->p_lock);
+ pthread_mutex_init(&part->p_lock, NULL);
part->total_size = size;
part->free = size;
part->id = id;
@@ -436,7 +442,7 @@ create_paging_partition(const char *name,
if (!part)
return;
- mutex_lock(&all_partitions.lock);
+ pthread_mutex_lock(&all_partitions.lock);
{
register int i;
@@ -462,7 +468,7 @@ create_paging_partition(const char *name,
}
set_partition_of(i, part);
}
- mutex_unlock(&all_partitions.lock);
+ pthread_mutex_unlock(&all_partitions.lock);
#if 0
dprintf("%s Added paging %s %s\n", my_name,
@@ -486,7 +492,7 @@ choose_partition(size, cur_part)
register boolean_t found = FALSE;
register int i;
- mutex_lock(&all_partitions.lock);
+ pthread_mutex_lock(&all_partitions.lock);
for (i = 0; i < all_partitions.n_partitions; i++) {
/* the undesirable one ? */
@@ -503,19 +509,19 @@ ddprintf ("choose_partition(%x,%d,%d)\n",size,cur_part,i);
continue;
/* is it big enough ? */
- mutex_lock(&part->p_lock);
+ pthread_mutex_lock(&part->p_lock);
if (ptoa(part->free) >= size) {
if (cur_part != P_INDEX_INVALID) {
- mutex_unlock(&all_partitions.lock);
+ pthread_mutex_unlock(&all_partitions.lock);
return (p_index_t)i;
} else
found = TRUE;
}
- mutex_unlock(&part->p_lock);
+ pthread_mutex_unlock(&part->p_lock);
if (found) break;
}
- mutex_unlock(&all_partitions.lock);
+ pthread_mutex_unlock(&all_partitions.lock);
return (found) ? (p_index_t)i : P_INDEX_INVALID;
}
@@ -545,11 +551,11 @@ ddprintf ("pager_alloc_page(%d,%d)\n",pindex,lock_it);
return (NO_BLOCK);
if (lock_it)
- mutex_lock(&part->p_lock);
+ pthread_mutex_lock(&part->p_lock);
if (part->free == 0) {
/* out of paging space */
- mutex_unlock(&part->p_lock);
+ pthread_mutex_unlock(&part->p_lock);
return (NO_BLOCK);
}
@@ -579,7 +585,7 @@ ddprintf ("pager_alloc_page(%d,%d)\n",pindex,lock_it);
}
- mutex_unlock(&part->p_lock);
+ pthread_mutex_unlock(&part->p_lock);
return (bm_e*NB_BM+bit);
}
@@ -609,13 +615,13 @@ ddprintf ("pager_dealloc_page(%d,%x,%d)\n",pindex,page,lock_it);
bit = page % NB_BM;
if (lock_it)
- mutex_lock(&part->p_lock);
+ pthread_mutex_lock(&part->p_lock);
part->bitmap[bm_e] &= ~(1<<bit);
part->free++;
if (lock_it)
- mutex_unlock(&part->p_lock);
+ pthread_mutex_unlock(&part->p_lock);
}
/*
@@ -659,7 +665,7 @@ typedef union dp_map *dp_map_t;
#define invalidate_block(e) ((e).indirect = (dp_map_t)NO_BLOCK)
struct dpager {
- struct mutex lock; /* lock for extending block map */
+ pthread_mutex_t lock; /* lock for extending block map */
/* XXX should be read-write lock */
#if DEBUG_READER_CONFLICTS
int readers;
@@ -751,7 +757,7 @@ pager_alloc(pager, part, size)
register int i;
register dp_map_t mapptr, emapptr;
- mutex_init(&pager->lock);
+ pthread_mutex_init(&pager->lock, NULL);
#if DEBUG_READER_CONFLICTS
pager->readers = 0;
pager->writer = FALSE;
@@ -900,7 +906,7 @@ pager_extend(pager, new_size)
register int i;
register vm_size_t old_size;
- mutex_lock(&pager->lock); /* XXX lock_write */
+ pthread_mutex_lock(&pager->lock); /* XXX lock_write */
#if DEBUG_READER_CONFLICTS
pager->writer = TRUE;
#endif
@@ -948,7 +954,7 @@ pager_extend(pager, new_size)
#if DEBUG_READER_CONFLICTS
pager->writer = FALSE;
#endif
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
#if 0
ddprintf ("pager_extend 1 mapptr %x [3b] = %x\n", new_mapptr,
new_mapptr[0x3b]);
@@ -1023,7 +1029,7 @@ pager_extend(pager, new_size)
#if DEBUG_READER_CONFLICTS
pager->writer = FALSE;
#endif
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
return;
}
/*
@@ -1052,7 +1058,7 @@ pager_extend(pager, new_size)
#if DEBUG_READER_CONFLICTS
pager->writer = FALSE;
#endif
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
}
/* Truncate a memory object. First, any pages between the new size
@@ -1091,7 +1097,7 @@ pager_truncate(dpager_t pager, vm_size_t new_size) /* in pages */
}
}
- mutex_lock(&pager->lock); /* XXX lock_write */
+ pthread_mutex_lock(&pager->lock); /* XXX lock_write */
if (!pager->map)
goto done;
@@ -1152,7 +1158,7 @@ pager_truncate(dpager_t pager, vm_size_t new_size) /* in pages */
done:
pager->size = new_size;
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
#ifdef CHECKSUM
#error write me
@@ -1180,7 +1186,7 @@ pager_read_offset(pager, offset)
default_pager_read_conflicts++; /* would have proceeded with
read/write lock */
#endif
- mutex_lock(&pager->lock); /* XXX lock_read */
+ pthread_mutex_lock(&pager->lock); /* XXX lock_read */
#if DEBUG_READER_CONFLICTS
pager->readers++;
#endif
@@ -1188,7 +1194,7 @@ pager_read_offset(pager, offset)
{
ddprintf ("%spager_read_offset pager %x: bad page %d >= size %d",
my_name, pager, f_page, pager->size);
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
return (union dp_map) (union dp_map *) NO_BLOCK;
#if 0
panic("%spager_read_offset",my_name);
@@ -1213,7 +1219,7 @@ pager_read_offset(pager, offset)
#if DEBUG_READER_CONFLICTS
pager->readers--;
#endif
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
return (pager_offset);
}
@@ -1229,7 +1235,7 @@ void pager_release_offset(pager, offset)
offset = atop(offset);
- mutex_lock(&pager->lock); /* XXX lock_read */
+ pthread_mutex_lock(&pager->lock); /* XXX lock_read */
assert (pager->map);
if (INDIRECT_PAGEMAP(pager->size)) {
@@ -1243,7 +1249,7 @@ void pager_release_offset(pager, offset)
invalidate_block(pager->map[offset]);
}
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
pager_dealloc_page(entry.block.p_index, entry.block.p_offset, TRUE);
}
@@ -1329,7 +1335,7 @@ pager_get_checksum(pager, offset)
f_page = atop(offset);
- mutex_lock(&pager->lock); /* XXX lock_read */
+ pthread_mutex_lock(&pager->lock); /* XXX lock_read */
if (f_page >= pager->size)
panic("%spager_get_checksum",my_name);
@@ -1346,7 +1352,7 @@ pager_get_checksum(pager, offset)
checksum = pager->checksum[f_page];
}
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
return (checksum);
}
@@ -1364,7 +1370,7 @@ pager_put_checksum(pager, offset, checksum)
f_page = atop(offset);
- mutex_lock(&pager->lock); /* XXX lock_read */
+ pthread_mutex_lock(&pager->lock); /* XXX lock_read */
if (f_page >= pager->size)
panic(here,my_name);
@@ -1380,7 +1386,7 @@ pager_put_checksum(pager, offset, checksum)
else {
pager->checksum[f_page] = checksum;
}
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
}
/*
@@ -1431,7 +1437,7 @@ pager_write_offset(pager, offset)
default_pager_read_conflicts++; /* would have proceeded with
read/write lock */
#endif
- mutex_lock(&pager->lock); /* XXX lock_read */
+ pthread_mutex_lock(&pager->lock); /* XXX lock_read */
#if DEBUG_READER_CONFLICTS
pager->readers++;
#endif
@@ -1463,14 +1469,14 @@ pager_write_offset(pager, offset)
#if DEBUG_READER_CONFLICTS
pager->readers--;
#endif
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
pager_extend(pager, f_page + 1);
#if DEBUG_READER_CONFLICTS
if (pager->readers > 0)
default_pager_read_conflicts++; /* would have proceeded with
read/write lock */
#endif
- mutex_lock(&pager->lock); /* XXX lock_read */
+ pthread_mutex_lock(&pager->lock); /* XXX lock_read */
#if DEBUG_READER_CONFLICTS
pager->readers++;
#endif
@@ -1573,7 +1579,7 @@ out:
#if DEBUG_READER_CONFLICTS
pager->readers--;
#endif
- mutex_unlock(&pager->lock);
+ pthread_mutex_unlock(&pager->lock);
return (block);
}
@@ -1886,8 +1892,8 @@ default_has_page(ds, offset)
struct dstruct {
queue_chain_t links; /* Link in pager-port list */
- struct mutex lock; /* Lock for the structure */
- struct condition
+ pthread_mutex_t lock; /* Lock for the structure */
+ pthread_cond_t
waiting_seqno, /* someone waiting on seqno */
waiting_read, /* someone waiting on readers */
waiting_write, /* someone waiting on writers */
@@ -1915,9 +1921,9 @@ typedef struct dstruct * default_pager_t;
#define DEFAULT_PAGER_NULL ((default_pager_t)0)
#if PARALLEL
-#define dstruct_lock_init(ds) mutex_init(&ds->lock)
-#define dstruct_lock(ds) mutex_lock(&ds->lock)
-#define dstruct_unlock(ds) mutex_unlock(&ds->lock)
+#define dstruct_lock_init(ds) pthread_mutex_init(&ds->lock, NULL)
+#define dstruct_lock(ds) pthread_mutex_lock(&ds->lock)
+#define dstruct_unlock(ds) pthread_mutex_unlock(&ds->lock)
#else /* PARALLEL */
#define dstruct_lock_init(ds)
#define dstruct_lock(ds)
@@ -1932,14 +1938,14 @@ typedef struct dstruct * default_pager_t;
*/
struct pager_port {
queue_head_t queue;
- struct mutex lock;
+ pthread_mutex_t lock;
int count; /* saves code */
queue_head_t leak_queue;
} all_pagers;
#define pager_port_list_init() \
{ \
- mutex_init(&all_pagers.lock); \
+ pthread_mutex_init(&all_pagers.lock, NULL); \
queue_init(&all_pagers.queue); \
queue_init(&all_pagers.leak_queue); \
all_pagers.count = 0; \
@@ -1949,10 +1955,10 @@ void pager_port_list_insert(port, ds)
mach_port_t port;
default_pager_t ds;
{
- mutex_lock(&all_pagers.lock);
+ pthread_mutex_lock(&all_pagers.lock);
queue_enter(&all_pagers.queue, ds, default_pager_t, links);
all_pagers.count++;
- mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&all_pagers.lock);
}
/* given a data structure return a good port-name to associate it to */
@@ -1969,10 +1975,10 @@ void pager_port_list_insert(port, ds)
void pager_port_list_delete(ds)
default_pager_t ds;
{
- mutex_lock(&all_pagers.lock);
+ pthread_mutex_lock(&all_pagers.lock);
queue_remove(&all_pagers.queue, ds, default_pager_t, links);
all_pagers.count--;
- mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&all_pagers.lock);
}
/*
@@ -1995,17 +2001,17 @@ destroy_paging_partition(name, pp_private)
* This prevents choose_partition from
* getting in the way.
*/
- mutex_lock(&all_partitions.lock);
+ pthread_mutex_lock(&all_partitions.lock);
for (pindex = 0; pindex < all_partitions.n_partitions; pindex++) {
part = partition_of(pindex);
if (part && (part->id == id)) break;
}
if (pindex == all_partitions.n_partitions) {
- mutex_unlock(&all_partitions.lock);
+ pthread_mutex_unlock(&all_partitions.lock);
return KERN_INVALID_ARGUMENT;
}
part->going_away = TRUE;
- mutex_unlock(&all_partitions.lock);
+ pthread_mutex_unlock(&all_partitions.lock);
/*
* This might take a while..
@@ -2015,18 +2021,18 @@ all_over_again:
dprintf("Partition x%x (id x%x) for %s, all_ok %d\n", part, id, name, all_ok);
#endif
all_ok = TRUE;
- mutex_lock(&part->p_lock);
+ pthread_mutex_lock(&part->p_lock);
- mutex_lock(&all_pagers.lock);
+ pthread_mutex_lock(&all_pagers.lock);
queue_iterate(&all_pagers.queue, entry, default_pager_t, links) {
dstruct_lock(entry);
- if (!mutex_try_lock(&entry->dpager.lock)) {
+ if (pthread_mutex_trylock(&entry->dpager.lock)) {
dstruct_unlock(entry);
- mutex_unlock(&all_pagers.lock);
- mutex_unlock(&part->p_lock);
+ pthread_mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&part->p_lock);
/* yield the processor */
(void) thread_switch(MACH_PORT_NULL,
@@ -2042,13 +2048,13 @@ dprintf("Partition x%x (id x%x) for %s, all_ok %d\n", part, id, name, all_ok);
*/
all_ok = pager_realloc(&entry->dpager, pindex);
- mutex_unlock(&entry->dpager.lock);
+ pthread_mutex_unlock(&entry->dpager.lock);
dstruct_unlock(entry);
if (!all_ok) break;
}
- mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&all_pagers.lock);
if (all_ok) {
/* No need to unlock partition, there are no refs left */
@@ -2098,7 +2104,7 @@ void pager_port_lock(ds, seqno)
dstruct_lock(ds);
while (ds->seqno != seqno) {
default_pager_wait_seqno++;
- condition_wait(&ds->waiting_seqno, &ds->lock);
+ pthread_cond_wait(&ds->waiting_seqno, &ds->lock);
}
}
@@ -2110,7 +2116,7 @@ void pager_port_unlock(ds)
{
ds->seqno++;
dstruct_unlock(ds);
- condition_broadcast(&ds->waiting_seqno);
+ pthread_cond_broadcast(&ds->waiting_seqno);
}
/*
@@ -2130,7 +2136,7 @@ void pager_port_wait_for_readers(ds)
{
while (ds->readers != 0) {
default_pager_wait_read++;
- condition_wait(&ds->waiting_read, &ds->lock);
+ pthread_cond_wait(&ds->waiting_read, &ds->lock);
}
}
@@ -2143,7 +2149,7 @@ void pager_port_finish_read(ds)
dstruct_lock(ds);
if (--ds->readers == 0) {
dstruct_unlock(ds);
- condition_broadcast(&ds->waiting_read);
+ pthread_cond_broadcast(&ds->waiting_read);
}
else {
dstruct_unlock(ds);
@@ -2167,7 +2173,7 @@ void pager_port_wait_for_writers(ds)
{
while (ds->writers != 0) {
default_pager_wait_write++;
- condition_wait(&ds->waiting_write, &ds->lock);
+ pthread_cond_wait(&ds->waiting_write, &ds->lock);
}
}
@@ -2180,7 +2186,7 @@ void pager_port_finish_write(ds)
dstruct_lock(ds);
if (--ds->writers == 0) {
dstruct_unlock(ds);
- condition_broadcast(&ds->waiting_write);
+ pthread_cond_broadcast(&ds->waiting_write);
}
else {
dstruct_unlock(ds);
@@ -2196,7 +2202,7 @@ void pager_port_wait_for_refs(ds)
{
while (ds->name_refs == 0) {
default_pager_wait_refs++;
- condition_wait(&ds->waiting_refs, &ds->lock);
+ pthread_cond_wait(&ds->waiting_refs, &ds->lock);
}
}
@@ -2206,7 +2212,7 @@ void pager_port_wait_for_refs(ds)
void pager_port_finish_refs(ds)
default_pager_t ds;
{
- condition_broadcast(&ds->waiting_refs);
+ pthread_cond_broadcast(&ds->waiting_refs);
}
#else /* PARALLEL */
@@ -2239,7 +2245,7 @@ mach_port_t default_pager_external_set; /* Port set for external objects. */
mach_port_t default_pager_default_set; /* Port set for "default" thread. */
typedef struct default_pager_thread {
- cthread_t dpt_thread; /* Server thread. */
+ pthread_t dpt_thread; /* Server thread. */
vm_offset_t dpt_buffer; /* Read buffer. */
boolean_t dpt_internal; /* Do we handle internal objects? */
} default_pager_thread_t;
@@ -2410,9 +2416,9 @@ rename_it:
panic("%s m_o_create", my_name);
ds1 = (default_pager_t) kalloc(sizeof *ds1);
*ds1 = *ds;
- mutex_lock(&all_pagers.lock);
+ pthread_mutex_lock(&all_pagers.lock);
queue_enter(&all_pagers.leak_queue, ds, default_pager_t, links);
- mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&all_pagers.lock);
ds = ds1;
goto rename_it;
}
@@ -2620,7 +2626,7 @@ void default_pager_no_senders(pager, seqno, mscount)
* Recover memory that we might have wasted because
* of name conflicts
*/
- mutex_lock(&all_pagers.lock);
+ pthread_mutex_lock(&all_pagers.lock);
while (!queue_empty(&all_pagers.leak_queue)) {
@@ -2629,12 +2635,14 @@ void default_pager_no_senders(pager, seqno, mscount)
kfree((char *) ds, sizeof(*ds));
}
- mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&all_pagers.lock);
}
int default_pager_pagein_count = 0;
int default_pager_pageout_count = 0;
+static __thread default_pager_thread_t *dpt;
+
kern_return_t
seqnos_memory_object_data_request(pager, seqno, reply_to, offset,
length, protection_required)
@@ -2645,15 +2653,12 @@ seqnos_memory_object_data_request(pager, seqno, reply_to, offset,
vm_size_t length;
vm_prot_t protection_required;
{
- default_pager_thread_t *dpt;
default_pager_t ds;
vm_offset_t addr;
unsigned int errors;
kern_return_t rc;
static char here[] = "%sdata_request";
- dpt = (default_pager_thread_t *) cthread_data(cthread_self());
-
if (length != vm_page_size)
panic(here,my_name);
@@ -3103,14 +3108,12 @@ default_pager_thread_privileges()
/*
* Set thread privileges.
*/
- cthread_wire(); /* attach kernel thread to cthread */
wire_thread(); /* grab a kernel stack and memory allocation
privileges */
}
-any_t
-default_pager_default_thread (arg)
- any_t arg;
+void *
+default_pager_default_thread(void *arg)
{
kern_return_t kr;
default_pager_thread_privileges ();
@@ -3124,16 +3127,13 @@ default_pager_default_thread (arg)
-any_t
-default_pager_thread(arg)
- any_t arg;
+void *
+default_pager_thread(void *arg)
{
- default_pager_thread_t *dpt = (default_pager_thread_t *) arg;
mach_port_t pset;
kern_return_t kr;
- cthread_set_data(cthread_self(), (any_t) dpt);
-
+ dpt = (default_pager_thread_t *) arg;
/*
* Threads handling external objects cannot have
@@ -3162,23 +3162,31 @@ void
start_default_pager_thread(internal)
boolean_t internal;
{
- default_pager_thread_t *dpt;
+ default_pager_thread_t *ndpt;
kern_return_t kr;
+ error_t err;
- dpt = (default_pager_thread_t *) kalloc(sizeof *dpt);
- if (dpt == 0)
+ ndpt = (default_pager_thread_t *) kalloc(sizeof *ndpt);
+ if (ndpt == 0)
panic(my_name);
- dpt->dpt_internal = internal;
+ ndpt->dpt_internal = internal;
- kr = vm_allocate(default_pager_self, &dpt->dpt_buffer,
+ kr = vm_allocate(default_pager_self, &ndpt->dpt_buffer,
vm_page_size, TRUE);
if (kr != KERN_SUCCESS)
panic(my_name);
- wire_memory(dpt->dpt_buffer, vm_page_size,
+ wire_memory(ndpt->dpt_buffer, vm_page_size,
VM_PROT_READ|VM_PROT_WRITE);
- dpt->dpt_thread = cthread_fork(default_pager_thread, (any_t) dpt);
+ err = pthread_create(&ndpt->dpt_thread, NULL, default_pager_thread,
+ ndpt);
+ if (!err)
+ pthread_detach (ndpt->dpt_thread);
+ else {
+ errno = err;
+ perror ("pthread_create");
+ }
}
void
@@ -3335,9 +3343,9 @@ rename_it:
ds1 = (default_pager_t) kalloc(sizeof *ds1);
*ds1 = *ds;
- mutex_lock(&all_pagers.lock);
+ pthread_mutex_lock(&all_pagers.lock);
queue_enter(&all_pagers.leak_queue, ds, default_pager_t, links);
- mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&all_pagers.lock);
ds = ds1;
goto rename_it;
}
@@ -3365,9 +3373,9 @@ S_default_pager_info (mach_port_t pager,
if (pager != default_pager_default_port)
return KERN_INVALID_ARGUMENT;
- mutex_lock(&all_partitions.lock);
+ pthread_mutex_lock(&all_partitions.lock);
paging_space_info(&total, &free);
- mutex_unlock(&all_partitions.lock);
+ pthread_mutex_unlock(&all_partitions.lock);
infop->dpi_total_space = ptoa(total);
infop->dpi_free_space = ptoa(free);
@@ -3410,12 +3418,12 @@ S_default_pager_objects (mach_port_t pager,
ports = *portsp;
ppotential = *pcountp;
- mutex_lock(&all_pagers.lock);
+ pthread_mutex_lock(&all_pagers.lock);
/*
* We will send no more than this many
*/
actual = all_pagers.count;
- mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&all_pagers.lock);
if (opotential < actual) {
vm_offset_t newaddr;
@@ -3453,7 +3461,7 @@ S_default_pager_objects (mach_port_t pager,
* Now scan the list.
*/
- mutex_lock(&all_pagers.lock);
+ pthread_mutex_lock(&all_pagers.lock);
num_pagers = 0;
queue_iterate(&all_pagers.queue, entry, default_pager_t, links) {
@@ -3474,10 +3482,10 @@ S_default_pager_objects (mach_port_t pager,
/*
* Avoid interfering with normal operations
*/
- if (!mutex_try_lock(&entry->dpager.lock))
+ if (pthread_mutex_trylock(&entry->dpager.lock))
goto not_this_one;
size = pager_allocated(&entry->dpager);
- mutex_unlock(&entry->dpager.lock);
+ pthread_mutex_unlock(&entry->dpager.lock);
dstruct_lock(entry);
@@ -3533,7 +3541,7 @@ not_this_one:
}
- mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&all_pagers.lock);
/*
* Deallocate and clear unused memory.
@@ -3633,16 +3641,16 @@ S_default_pager_object_pages (mach_port_t pager,
for (;;) {
default_pager_t entry;
- mutex_lock(&all_pagers.lock);
+ pthread_mutex_lock(&all_pagers.lock);
queue_iterate(&all_pagers.queue, entry, default_pager_t, links) {
dstruct_lock(entry);
if (entry->pager_name == object) {
- mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&all_pagers.lock);
goto found_object;
}
dstruct_unlock(entry);
}
- mutex_unlock(&all_pagers.lock);
+ pthread_mutex_unlock(&all_pagers.lock);
/* did not find the object */
@@ -3652,7 +3660,7 @@ S_default_pager_object_pages (mach_port_t pager,
found_object:
- if (!mutex_try_lock(&entry->dpager.lock)) {
+ if (pthread_mutex_trylock(&entry->dpager.lock)) {
/* oh well bad luck */
dstruct_unlock(entry);
@@ -3664,7 +3672,7 @@ S_default_pager_object_pages (mach_port_t pager,
}
actual = pager_pages(&entry->dpager, pages, potential);
- mutex_unlock(&entry->dpager.lock);
+ pthread_mutex_unlock(&entry->dpager.lock);
dstruct_unlock(entry);
if (actual <= potential)
diff --git a/mach-defpager/kalloc.c b/mach-defpager/kalloc.c
index d9b18c02..8efb85f9 100644
--- a/mach-defpager/kalloc.c
+++ b/mach-defpager/kalloc.c
@@ -33,7 +33,7 @@
*/
#include <mach.h>
-#include <cthreads.h> /* for spin locks */
+#include <pthread.h> /* for spin locks */
#include <malloc.h> /* for malloc_hook/free_hook */
#include "wiring.h"
@@ -61,10 +61,10 @@ vm_size_t kalloc_max; /* max before we use vm_allocate */
#define MINSIZE 4 /* minimum allocation size */
struct free_list {
- spin_lock_t lock;
- vm_offset_t head; /* head of free list */
+ pthread_spinlock_t lock;
+ vm_offset_t head; /* head of free list */
#ifdef DEBUG
- int count;
+ int count;
#endif /*DEBUG*/
};
@@ -74,7 +74,7 @@ struct free_list {
2048, 4096, 8192, 16384 */
struct free_list kfree_list[KLIST_MAX];
-spin_lock_t kget_space_lock;
+pthread_spinlock_t kget_space_lock;
vm_offset_t kalloc_next_space = 0;
vm_offset_t kalloc_end_of_space = 0;
@@ -107,10 +107,10 @@ void kalloc_init(void)
kalloc_max = vm_page_size;
for (i = 0; i < KLIST_MAX; i++) {
- spin_lock_init(&kfree_list[i].lock);
+ pthread_spin_init(&kfree_list[i].lock, PTHREAD_PROCESS_PRIVATE);
kfree_list[i].head = 0;
}
- spin_lock_init(&kget_space_lock);
+ pthread_spin_init(&kget_space_lock, PTHREAD_PROCESS_PRIVATE);
/*
* Do not allocate memory at address 0.
@@ -128,7 +128,7 @@ vm_offset_t kget_space(vm_offset_t size)
vm_offset_t new_space = 0;
vm_offset_t addr;
- spin_lock(&kget_space_lock);
+ pthread_spin_lock(&kget_space_lock);
while (kalloc_next_space + size > kalloc_end_of_space) {
/*
* Add at least one page to allocation area.
@@ -141,7 +141,7 @@ vm_offset_t kget_space(vm_offset_t size)
* Try to make it contiguous with the last
* allocation area.
*/
- spin_unlock(&kget_space_lock);
+ pthread_spin_unlock(&kget_space_lock);
new_space = kalloc_end_of_space;
if (vm_map(mach_task_self(),
@@ -152,7 +152,7 @@ vm_offset_t kget_space(vm_offset_t size)
return 0;
wire_memory(new_space, space_to_add,
VM_PROT_READ|VM_PROT_WRITE);
- spin_lock(&kget_space_lock);
+ pthread_spin_lock(&kget_space_lock);
continue;
}
@@ -177,7 +177,7 @@ vm_offset_t kget_space(vm_offset_t size)
addr = kalloc_next_space;
kalloc_next_space += size;
- spin_unlock(&kget_space_lock);
+ pthread_spin_unlock(&kget_space_lock);
if (new_space != 0)
(void) vm_deallocate(mach_task_self(), new_space, space_to_add);
@@ -214,16 +214,16 @@ void *kalloc(vm_size_t size)
*/
if (allocsize < kalloc_max) {
- spin_lock(&fl->lock);
+ pthread_spin_lock(&fl->lock);
if ((addr = fl->head) != 0) {
fl->head = *(vm_offset_t *)addr;
#ifdef DEBUG
fl->count--;
#endif
- spin_unlock(&fl->lock);
+ pthread_spin_unlock(&fl->lock);
}
else {
- spin_unlock(&fl->lock);
+ pthread_spin_unlock(&fl->lock);
addr = kget_space(allocsize);
}
}
@@ -253,13 +253,13 @@ kfree( void *data,
}
if (freesize < kalloc_max) {
- spin_lock(&fl->lock);
+ pthread_spin_lock(&fl->lock);
*(vm_offset_t *)data = fl->head;
fl->head = (vm_offset_t) data;
#ifdef DEBUG
fl->count++;
#endif
- spin_unlock(&fl->lock);
+ pthread_spin_unlock(&fl->lock);
}
else {
(void) vm_deallocate(mach_task_self(), (vm_offset_t)data, freesize);
diff --git a/mach-defpager/main.c b/mach-defpager/main.c
index c44c86cb..3134d6f3 100644
--- a/mach-defpager/main.c
+++ b/mach-defpager/main.c
@@ -21,7 +21,7 @@
#include <mach.h>
#include <hurd.h>
-#include <cthreads.h>
+#include <pthread.h>
#include <device/device.h>
#include <device/device_types.h>
@@ -45,9 +45,6 @@
#include <default_pager.h>
-extern
-vm_size_t cthread_wait_stack_size;
-
mach_port_t bootstrap_master_device_port; /* local name */
mach_port_t bootstrap_master_host_port; /* local name */
@@ -87,11 +84,6 @@ main (int argc, char **argv)
error_t err;
memory_object_t defpager;
- /*
- * Use 4Kbyte cthread wait stacks.
- */
- cthread_wait_stack_size = 4 * 1024;
-
err = get_privileged_ports (&bootstrap_master_host_port,
&bootstrap_master_device_port);
if (err)