| 1 | /*
|
|---|
| 2 | * Copyright (c) 1994 by Xerox Corporation. All rights reserved.
|
|---|
| 3 | *
|
|---|
| 4 | * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
|
|---|
| 5 | * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
|
|---|
| 6 | *
|
|---|
| 7 | * Permission is hereby granted to use or copy this program
|
|---|
| 8 | * for any purpose, provided the above notices are retained on all copies.
|
|---|
| 9 | * Permission to modify the code and to distribute modified code is granted,
|
|---|
| 10 | * provided the above notices are retained, and a notice that the code was
|
|---|
| 11 | * modified is included with the above copyright notice.
|
|---|
| 12 | */
|
|---|
| 13 | /*
|
|---|
| 14 | * Support code for Solaris threads. Provides functionality we wish Sun
|
|---|
| 15 | * had provided. Relies on some information we probably shouldn't rely on.
|
|---|
| 16 | * Modified Peter C. for Solaris Posix Threads.
|
|---|
| 17 | */
|
|---|
| 18 | /* Boehm, September 14, 1994 4:44 pm PDT */
|
|---|
| 19 |
|
|---|
| 20 | # if defined(GC_SOLARIS_PTHREADS)
|
|---|
| 21 | # include "private/gc_priv.h"
|
|---|
| 22 | # include <pthread.h>
|
|---|
| 23 | # include <thread.h>
|
|---|
| 24 | # include <signal.h>
|
|---|
| 25 | # include <fcntl.h>
|
|---|
| 26 | # include <sys/types.h>
|
|---|
| 27 | # include <sys/mman.h>
|
|---|
| 28 | # include <sys/time.h>
|
|---|
| 29 | # include <sys/resource.h>
|
|---|
| 30 | # include <sys/stat.h>
|
|---|
| 31 | # include <sys/syscall.h>
|
|---|
| 32 | # include <sys/procfs.h>
|
|---|
| 33 | # include <sys/lwp.h>
|
|---|
| 34 | # include <sys/reg.h>
|
|---|
| 35 | # define _CLASSIC_XOPEN_TYPES
|
|---|
| 36 | # include <unistd.h>
|
|---|
| 37 | # include <errno.h>
|
|---|
| 38 | # include "private/solaris_threads.h"
|
|---|
| 39 | # include <stdio.h>
|
|---|
| 40 |
|
|---|
| 41 | #undef pthread_join
|
|---|
| 42 | #undef pthread_create
|
|---|
| 43 |
|
|---|
| 44 | pthread_cond_t GC_prom_join_cv; /* Broadcast when any thread terminates */
|
|---|
| 45 | pthread_cond_t GC_create_cv; /* Signalled when a new undetached */
|
|---|
| 46 | /* thread starts. */
|
|---|
| 47 |
|
|---|
| 48 | extern GC_bool GC_multithreaded;
|
|---|
| 49 |
|
|---|
| 50 | /* We use the allocation lock to protect thread-related data structures. */
|
|---|
| 51 |
|
|---|
| 52 | /* We stop the world using /proc primitives. This makes some */
|
|---|
| 53 | /* minimal assumptions about the threads implementation. */
|
|---|
| 54 | /* We don't play by the rules, since the rules make this */
|
|---|
| 55 | /* impossible (as of Solaris 2.3). Also note that as of */
|
|---|
| 56 | /* Solaris 2.3 the various thread and lwp suspension */
|
|---|
| 57 | /* primitives failed to stop threads by the time the request */
|
|---|
| 58 | /* is completed. */
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 | int GC_pthread_join(pthread_t wait_for, void **status)
|
|---|
| 63 | {
|
|---|
| 64 | return GC_thr_join((thread_t)wait_for, NULL, status);
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 | int
|
|---|
| 69 | GC_pthread_create(pthread_t *new_thread,
|
|---|
| 70 | const pthread_attr_t *attr_in,
|
|---|
| 71 | void * (*thread_execp)(void *), void *arg)
|
|---|
| 72 | {
|
|---|
| 73 | int result;
|
|---|
| 74 | GC_thread t;
|
|---|
| 75 | pthread_t my_new_thread;
|
|---|
| 76 | pthread_attr_t attr;
|
|---|
|
|---|