Rev 1091 | Rev 1113 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1091 | Rev 1111 | ||
|---|---|---|---|
| Line 31... | Line 31... | ||
| 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) |
| Line 241... | Line 250... | ||
| 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 | ||
| Line 253... | Line 264... | ||
| 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 | } |