Rev 1091 | Rev 1113 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1091 | Rev 1111 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (C) 2005 Martin Decky |
2 | * Copyright (C) 2005 Martin Decky |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | #include "version.h" |
29 | #include "version.h" |
30 | #include <ipc.h> |
30 | #include <ipc.h> |
31 | #include <stdio.h> |
31 | #include <stdio.h> |
32 | #include <unistd.h> |
32 | #include <unistd.h> |
33 | #include <stdlib.h> |
33 | #include <stdlib.h> |
34 | #include <ns.h> |
34 | #include <ns.h> |
35 | #include <thread.h> |
35 | #include <thread.h> |
- | 36 | #include <futex.h> |
|
36 | 37 | ||
37 | int a; |
38 | int a; |
- | 39 | atomic_t ftx; |
|
38 | 40 | ||
39 | extern void utest(void *arg); |
41 | extern void utest(void *arg); |
40 | void utest(void *arg) |
42 | void utest(void *arg) |
41 | { |
43 | { |
42 | printf("Uspace thread started.\n"); |
44 | printf("Uspace thread started.\n"); |
- | 45 | if (futex_down(&ftx) < 0) |
|
- | 46 | printf("Futex failed.\n"); |
|
- | 47 | if (futex_up(&ftx) < 0) |
|
- | 48 | printf("Futex failed.\n"); |
|
- | 49 | ||
- | 50 | printf("%s in good condition.\n", __FUNCTION__); |
|
- | 51 | ||
43 | for (;;) |
52 | for (;;) |
44 | ; |
53 | ; |
45 | } |
54 | } |
46 | 55 | ||
47 | static void test_printf(void) |
56 | static void test_printf(void) |
48 | { |
57 | { |
49 | printf("Simple text.\n"); |
58 | printf("Simple text.\n"); |
50 | printf("Now insert '%s' string.\n","this"); |
59 | printf("Now insert '%s' string.\n","this"); |
51 | printf("Signed formats on uns. numbers: '%d', '%+d', '% d', '%u' (,+, ,u)\n", 321, 321, 321, 321); |
60 | printf("Signed formats on uns. numbers: '%d', '%+d', '% d', '%u' (,+, ,u)\n", 321, 321, 321, 321); |
52 | printf("Signed formats on sig. numbers: '%d', '%+d', '% d', '%u' (,+, ,u)\n", -321, -321, -321, -321); |
61 | printf("Signed formats on sig. numbers: '%d', '%+d', '% d', '%u' (,+, ,u)\n", -321, -321, -321, -321); |
53 | printf("Signed with different sized: '%hhd', '%hd', '%d', '%ld', %lld;\n", -3, -32, -321, -32101l, -3210123ll); |
62 | printf("Signed with different sized: '%hhd', '%hd', '%d', '%ld', %lld;\n", -3, -32, -321, -32101l, -3210123ll); |
54 | printf("And now... '%hhd' byte! '%hd' word! '%d' int! \n", 11, 11111, 1111111111); |
63 | printf("And now... '%hhd' byte! '%hd' word! '%d' int! \n", 11, 11111, 1111111111); |
55 | printf("Different bases: %#hx, %#hu, %#ho and %#hb\n", 123, 123, 123, 123); |
64 | printf("Different bases: %#hx, %#hu, %#ho and %#hb\n", 123, 123, 123, 123); |
56 | printf("Different bases signed: %#hx, %#hu, %#ho and %#hb\n", -123, -123, -123, -123); |
65 | printf("Different bases signed: %#hx, %#hu, %#ho and %#hb\n", -123, -123, -123, -123); |
57 | printf("'%llX' llX! Another '%llx' llx! \n", 0x1234567887654321ll, 0x1234567887654321ll); |
66 | printf("'%llX' llX! Another '%llx' llx! \n", 0x1234567887654321ll, 0x1234567887654321ll); |
58 | printf("'%llX' with 64bit value and '%x' with 32 bit value. \n", 0x1234567887654321ll, 0x12345678 ); |
67 | printf("'%llX' with 64bit value and '%x' with 32 bit value. \n", 0x1234567887654321ll, 0x12345678 ); |
59 | printf("'%llx' 64bit, '%x' 32bit, '%hhx' 8bit, '%hx' 16bit, '%llX' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, 0x1234567887654321ull, "Lovely string" ); |
68 | printf("'%llx' 64bit, '%x' 32bit, '%hhx' 8bit, '%hx' 16bit, '%llX' 64bit and '%s' string.\n", 0x1234567887654321ll, 0x12345678, 0x12, 0x1234, 0x1234567887654321ull, "Lovely string" ); |
60 | 69 | ||
61 | printf("Thats all, folks!\n"); |
70 | printf("Thats all, folks!\n"); |
62 | } |
71 | } |
63 | 72 | ||
64 | 73 | ||
65 | extern char _heap; |
74 | extern char _heap; |
66 | static void test_mremap(void) |
75 | static void test_mremap(void) |
67 | { |
76 | { |
68 | printf("Writing to good memory\n"); |
77 | printf("Writing to good memory\n"); |
69 | mremap(&_heap, 120000, 0); |
78 | mremap(&_heap, 120000, 0); |
70 | printf("%P\n", ((char *)&_heap)); |
79 | printf("%P\n", ((char *)&_heap)); |
71 | printf("%P\n", ((char *)&_heap) + 80000); |
80 | printf("%P\n", ((char *)&_heap) + 80000); |
72 | *(((char *)&_heap) + 80000) = 10; |
81 | *(((char *)&_heap) + 80000) = 10; |
73 | printf("Making small\n"); |
82 | printf("Making small\n"); |
74 | mremap(&_heap, 16000, 0); |
83 | mremap(&_heap, 16000, 0); |
75 | printf("Failing..\n"); |
84 | printf("Failing..\n"); |
76 | *((&_heap) + 80000) = 10; |
85 | *((&_heap) + 80000) = 10; |
77 | 86 | ||
78 | printf("memory done\n"); |
87 | printf("memory done\n"); |
79 | } |
88 | } |
80 | /* |
89 | /* |
81 | static void test_sbrk(void) |
90 | static void test_sbrk(void) |
82 | { |
91 | { |
83 | printf("Writing to good memory\n"); |
92 | printf("Writing to good memory\n"); |
84 | printf("Got: %P\n", sbrk(120000)); |
93 | printf("Got: %P\n", sbrk(120000)); |
85 | printf("%P\n", ((char *)&_heap)); |
94 | printf("%P\n", ((char *)&_heap)); |
86 | printf("%P\n", ((char *)&_heap) + 80000); |
95 | printf("%P\n", ((char *)&_heap) + 80000); |
87 | *(((char *)&_heap) + 80000) = 10; |
96 | *(((char *)&_heap) + 80000) = 10; |
88 | printf("Making small, got: %P\n",sbrk(-120000)); |
97 | printf("Making small, got: %P\n",sbrk(-120000)); |
89 | printf("Testing access to heap\n"); |
98 | printf("Testing access to heap\n"); |
90 | _heap = 10; |
99 | _heap = 10; |
91 | printf("Failing..\n"); |
100 | printf("Failing..\n"); |
92 | *((&_heap) + 80000) = 10; |
101 | *((&_heap) + 80000) = 10; |
93 | 102 | ||
94 | printf("memory done\n"); |
103 | printf("memory done\n"); |
95 | } |
104 | } |
96 | */ |
105 | */ |
97 | /* |
106 | /* |
98 | static void test_malloc(void) |
107 | static void test_malloc(void) |
99 | { |
108 | { |
100 | char *data; |
109 | char *data; |
101 | 110 | ||
102 | data = malloc(10); |
111 | data = malloc(10); |
103 | printf("Heap: %P, data: %P\n", &_heap, data); |
112 | printf("Heap: %P, data: %P\n", &_heap, data); |
104 | data[0] = 'a'; |
113 | data[0] = 'a'; |
105 | free(data); |
114 | free(data); |
106 | } |
115 | } |
107 | */ |
116 | */ |
108 | 117 | ||
109 | 118 | ||
110 | static void test_ping(void) |
119 | static void test_ping(void) |
111 | { |
120 | { |
112 | ipcarg_t result; |
121 | ipcarg_t result; |
113 | int retval; |
122 | int retval; |
114 | 123 | ||
115 | printf("Pinging\n"); |
124 | printf("Pinging\n"); |
116 | retval = ipc_call_sync(PHONE_NS, NS_PING, 0xbeef,&result); |
125 | retval = ipc_call_sync(PHONE_NS, NS_PING, 0xbeef,&result); |
117 | printf("Retval: %d - received: %P\n", retval, result); |
126 | printf("Retval: %d - received: %P\n", retval, result); |
118 | } |
127 | } |
119 | 128 | ||
120 | static void got_answer(void *private, int retval, ipc_call_t *data) |
129 | static void got_answer(void *private, int retval, ipc_call_t *data) |
121 | { |
130 | { |
122 | printf("Retval: %d...%s...%zX, %zX\n", retval, private, |
131 | printf("Retval: %d...%s...%zX, %zX\n", retval, private, |
123 | IPC_GET_ARG1(*data), IPC_GET_ARG2(*data)); |
132 | IPC_GET_ARG1(*data), IPC_GET_ARG2(*data)); |
124 | } |
133 | } |
125 | static void test_async_ipc(void) |
134 | static void test_async_ipc(void) |
126 | { |
135 | { |
127 | ipc_call_t data; |
136 | ipc_call_t data; |
128 | int i; |
137 | int i; |
129 | 138 | ||
130 | printf("Sending ping\n"); |
139 | printf("Sending ping\n"); |
131 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
140 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
132 | "Pong1", got_answer); |
141 | "Pong1", got_answer); |
133 | ipc_call_async_2(PHONE_NS, NS_PING, 2, 0xbeefbee4, |
142 | ipc_call_async_2(PHONE_NS, NS_PING, 2, 0xbeefbee4, |
134 | "Pong2", got_answer); |
143 | "Pong2", got_answer); |
135 | ipc_call_async_2(PHONE_NS, NS_PING, 3, 0xbeefbee4, |
144 | ipc_call_async_2(PHONE_NS, NS_PING, 3, 0xbeefbee4, |
136 | "Pong3", got_answer); |
145 | "Pong3", got_answer); |
137 | ipc_call_async_2(PHONE_NS, NS_PING, 4, 0xbeefbee4, |
146 | ipc_call_async_2(PHONE_NS, NS_PING, 4, 0xbeefbee4, |
138 | "Pong4", got_answer); |
147 | "Pong4", got_answer); |
139 | ipc_call_async_2(PHONE_NS, NS_PING, 5, 0xbeefbee4, |
148 | ipc_call_async_2(PHONE_NS, NS_PING, 5, 0xbeefbee4, |
140 | "Pong5", got_answer); |
149 | "Pong5", got_answer); |
141 | ipc_call_async_2(PHONE_NS, NS_PING, 6, 0xbeefbee4, |
150 | ipc_call_async_2(PHONE_NS, NS_PING, 6, 0xbeefbee4, |
142 | "Pong6", got_answer); |
151 | "Pong6", got_answer); |
143 | printf("Waiting forever...\n"); |
152 | printf("Waiting forever...\n"); |
144 | for (i=0; i<100;i++) |
153 | for (i=0; i<100;i++) |
145 | printf("."); |
154 | printf("."); |
146 | printf("\n"); |
155 | printf("\n"); |
147 | ipc_wait_for_call(&data, NULL); |
156 | ipc_wait_for_call(&data, NULL); |
148 | printf("Received call???\n"); |
157 | printf("Received call???\n"); |
149 | } |
158 | } |
150 | 159 | ||
151 | 160 | ||
152 | static void got_answer_2(void *private, int retval, ipc_call_t *data) |
161 | static void got_answer_2(void *private, int retval, ipc_call_t *data) |
153 | { |
162 | { |
154 | printf("Pong\n"); |
163 | printf("Pong\n"); |
155 | } |
164 | } |
156 | static void test_advanced_ipc(void) |
165 | static void test_advanced_ipc(void) |
157 | { |
166 | { |
158 | int res; |
167 | int res; |
159 | ipcarg_t phonead; |
168 | ipcarg_t phonead; |
160 | ipc_callid_t callid; |
169 | ipc_callid_t callid; |
161 | ipc_call_t data; |
170 | ipc_call_t data; |
162 | int i; |
171 | int i; |
163 | 172 | ||
164 | printf("Asking 0 to connect to me...\n"); |
173 | printf("Asking 0 to connect to me...\n"); |
165 | res = ipc_connect_to_me(0, 1, 2, &phonead); |
174 | res = ipc_connect_to_me(0, 1, 2, &phonead); |
166 | printf("Result: %d - phonead: %llu\n", res, phonead); |
175 | printf("Result: %d - phonead: %llu\n", res, phonead); |
167 | for (i=0; i < 100; i++) { |
176 | for (i=0; i < 100; i++) { |
168 | printf("----------------\n"); |
177 | printf("----------------\n"); |
169 | ipc_call_async(PHONE_NS, NS_PING_SVC, 0, "prov", |
178 | ipc_call_async(PHONE_NS, NS_PING_SVC, 0, "prov", |
170 | got_answer_2); |
179 | got_answer_2); |
171 | callid = ipc_wait_for_call(&data, NULL); |
180 | callid = ipc_wait_for_call(&data, NULL); |
172 | printf("Received ping\n"); |
181 | printf("Received ping\n"); |
173 | ipc_answer(callid, 0, 0, 0); |
182 | ipc_answer(callid, 0, 0, 0); |
174 | } |
183 | } |
175 | // callid = ipc_wait_for_call(&data, NULL); |
184 | // callid = ipc_wait_for_call(&data, NULL); |
176 | } |
185 | } |
177 | 186 | ||
178 | static void test_connection_ipc(void) |
187 | static void test_connection_ipc(void) |
179 | { |
188 | { |
180 | int res; |
189 | int res; |
181 | ipcarg_t result; |
190 | ipcarg_t result; |
182 | int phoneid; |
191 | int phoneid; |
183 | 192 | ||
184 | printf("Starting connect...\n"); |
193 | printf("Starting connect...\n"); |
185 | res = ipc_connect_me_to(PHONE_NS, 10, 20); |
194 | res = ipc_connect_me_to(PHONE_NS, 10, 20); |
186 | printf("Connected: %d\n", res); |
195 | printf("Connected: %d\n", res); |
187 | printf("pinging.\n"); |
196 | printf("pinging.\n"); |
188 | res = ipc_call_sync(res, NS_PING, 0xbeef,&result); |
197 | res = ipc_call_sync(res, NS_PING, 0xbeef,&result); |
189 | printf("Retval: %d - received: %X\n", res, result); |
198 | printf("Retval: %d - received: %X\n", res, result); |
190 | 199 | ||
191 | } |
200 | } |
192 | 201 | ||
193 | static void test_hangup(void) |
202 | static void test_hangup(void) |
194 | { |
203 | { |
195 | int phoneid; |
204 | int phoneid; |
196 | ipc_call_t data; |
205 | ipc_call_t data; |
197 | ipc_callid_t callid; |
206 | ipc_callid_t callid; |
198 | int i; |
207 | int i; |
199 | 208 | ||
200 | printf("Starting connect...\n"); |
209 | printf("Starting connect...\n"); |
201 | phoneid = ipc_connect_me_to(PHONE_NS, 10, 20); |
210 | phoneid = ipc_connect_me_to(PHONE_NS, 10, 20); |
202 | printf("Phoneid: %d, pinging\n", phoneid); |
211 | printf("Phoneid: %d, pinging\n", phoneid); |
203 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
212 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
204 | "Pong1", got_answer); |
213 | "Pong1", got_answer); |
205 | printf("Hangin up\n"); |
214 | printf("Hangin up\n"); |
206 | ipc_hangup(phoneid); |
215 | ipc_hangup(phoneid); |
207 | printf("Connecting\n"); |
216 | printf("Connecting\n"); |
208 | phoneid = ipc_connect_me_to(PHONE_NS, 10, 20); |
217 | phoneid = ipc_connect_me_to(PHONE_NS, 10, 20); |
209 | printf("Newphid: %d\n", phoneid); |
218 | printf("Newphid: %d\n", phoneid); |
210 | for (i=0; i < 1000; i++) { |
219 | for (i=0; i < 1000; i++) { |
211 | if ((callid=ipc_wait_for_call(&data, IPC_WAIT_NONBLOCKING))) |
220 | if ((callid=ipc_wait_for_call(&data, IPC_WAIT_NONBLOCKING))) |
212 | printf("callid: %d\n"); |
221 | printf("callid: %d\n"); |
213 | } |
222 | } |
214 | printf("New new phoneid: %d\n", ipc_connect_me_to(PHONE_NS, 10, 20)); |
223 | printf("New new phoneid: %d\n", ipc_connect_me_to(PHONE_NS, 10, 20)); |
215 | } |
224 | } |
216 | 225 | ||
217 | static void test_slam(void) |
226 | static void test_slam(void) |
218 | { |
227 | { |
219 | int i; |
228 | int i; |
220 | ipc_call_t data; |
229 | ipc_call_t data; |
221 | ipc_callid_t callid; |
230 | ipc_callid_t callid; |
222 | 231 | ||
223 | printf("ping"); |
232 | printf("ping"); |
224 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
233 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
225 | "Pong1", got_answer); |
234 | "Pong1", got_answer); |
226 | printf("slam"); |
235 | printf("slam"); |
227 | ipc_call_async_2(PHONE_NS, NS_HANGUP, 1, 0xbeefbee2, |
236 | ipc_call_async_2(PHONE_NS, NS_HANGUP, 1, 0xbeefbee2, |
228 | "Hang", got_answer); |
237 | "Hang", got_answer); |
229 | printf("ping2\n"); |
238 | printf("ping2\n"); |
230 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
239 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
231 | "Ping2", got_answer); |
240 | "Ping2", got_answer); |
232 | 241 | ||
233 | for (i=0; i < 1000; i++) { |
242 | for (i=0; i < 1000; i++) { |
234 | if ((callid=ipc_wait_for_call(&data, IPC_WAIT_NONBLOCKING))) |
243 | if ((callid=ipc_wait_for_call(&data, IPC_WAIT_NONBLOCKING))) |
235 | printf("callid: %d\n"); |
244 | printf("callid: %d\n"); |
236 | } |
245 | } |
237 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
246 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
238 | "Pong1", got_answer); |
247 | "Pong1", got_answer); |
239 | printf("Closing file\n"); |
248 | printf("Closing file\n"); |
240 | ipc_hangup(PHONE_NS); |
249 | ipc_hangup(PHONE_NS); |
241 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
250 | ipc_call_async_2(PHONE_NS, NS_PING, 1, 0xbeefbee2, |
242 | "Pong1", got_answer); |
251 | "Pong1", got_answer); |
243 | ipc_wait_for_call(&data, 0); |
252 | ipc_wait_for_call(&data, 0); |
244 | } |
253 | } |
245 | 254 | ||
- | 255 | ||
- | 256 | ||
246 | int main(int argc, char *argv[]) |
257 | int main(int argc, char *argv[]) |
247 | { |
258 | { |
248 | int tid; |
259 | int tid; |
249 | version_print(); |
260 | version_print(); |
250 | 261 | ||
251 | /* test_printf(); */ |
262 | /* test_printf(); */ |
252 | // test_ping(); |
263 | // test_ping(); |
253 | // test_async_ipc(); |
264 | // test_async_ipc(); |
254 | // test_advanced_ipc(); |
265 | // test_advanced_ipc(); |
255 | // test_connection_ipc(); |
266 | // test_connection_ipc(); |
256 | // test_hangup(); |
267 | // test_hangup(); |
257 | // test_slam(); |
268 | // test_slam(); |
- | 269 | ||
- | 270 | futex_initialize(&ftx, 1); |
|
- | 271 | if (futex_down(&ftx) < 0) |
|
- | 272 | printf("Futex failed.\n"); |
|
- | 273 | if (futex_up(&ftx) < 0) |
|
- | 274 | printf("Futex failed.\n"); |
|
- | 275 | ||
- | 276 | if (futex_down(&ftx) < 0) |
|
- | 277 | printf("Futex failed.\n"); |
|
258 | 278 | ||
259 | if ((tid = thread_create(utest, NULL, "utest") != -1)) { |
279 | if ((tid = thread_create(utest, NULL, "utest") != -1)) { |
260 | printf("Created thread tid=%d\n", tid); |
280 | printf("Created thread tid=%d\n", tid); |
261 | } |
281 | } |
- | 282 | ||
- | 283 | int i; |
|
- | 284 | ||
- | 285 | for (i = 0; i < 10000000; i++) |
|
- | 286 | ; |
|
- | 287 | ||
- | 288 | if (futex_up(&ftx) < 0) |
|
- | 289 | printf("Futex failed.\n"); |
|
- | 290 | ||
- | 291 | printf("Main thread exiting.\n"); |
|
262 | return 0; |
292 | return 0; |
263 | } |
293 | } |
264 | 294 |