1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* Mach Operating System
* Copyright (c) 1992 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
/*
* HISTORY
* $Log: thread.c,v $
* Revision 1.1 2002/05/27 02:13:47 roland
* 2002-05-26 Roland McGrath <roland@frob.com>
*
* * alpha/cthreads.h, alpha/thread.c, alpha/csw.S, alpha/lock.S:
* New files, verbatim from CMU release MK83a user/threads/alpha.
*
* Revision 2.3 93/02/01 09:56:49 danner
* mach/mach.h -> mach.h
* [93/01/28 danner]
*
* Revision 2.2 93/01/14 18:04:35 danner
* Created.
* [92/05/31 af]
*
*/
/*
* alpha/thread.c
*
* Cproc startup for ALPHA Cthreads implementation.
*/
#include <cthreads.h>
#include "cthread_internals.h"
#include <mach.h>
#if 0
/*
* C library imports:
*/
extern bzero();
#endif
/*
* Set up the initial state of a MACH thread
* so that it will invoke routine(child)
* when it is resumed.
*/
#warning TLS support not implemented
void
cproc_setup(
register cproc_t child,
thread_t thread,
tcbhead_t *tcb,
void (*routine)(cproc_t))
{
register integer_t *top;
struct alpha_thread_state state;
register struct alpha_thread_state *ts;
kern_return_t r;
/*
* Set up ALPHA call frame and registers.
*/
ts = &state;
bzero((char *) ts, sizeof(struct alpha_thread_state));
top = (integer_t *) (child->stack_base + child->stack_size);
/*
* Set pc & pv to procedure entry, pass one arg in register,
* allocate room for 6 regsave on the stack frame (sanity).
*/
ts->pc = (natural_t) routine;
ts->r27 = (natural_t) routine;
ts->r16 = (integer_t) child;
ts->r30 = (integer_t) (top - 6); /* see ARG_SAVE in csw.s */
MACH_CALL(thread_set_state(thread,ALPHA_THREAD_STATE,(thread_state_t) &state,ALPHA_THREAD_STATE_COUNT),r);
}
|