summaryrefslogtreecommitdiff
path: root/src/modules/test/main.c
blob: d2a4692a45949573e62ec817f9e7a27174940d5a (plain) (blame)
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
#include <gc/syscall.h>

#define FACTOR 4

int obj = -1;

void thread2(void* d) {
	printk("[module:test:2] Creating new object...\n");
	obj = object_create();
	struct user_request rq;
	while (1) {
		printk("[module:test:2] Waiting for a request...\n");
		request_get(obj, &rq, 1);
		if (rq.isBlocking) {
			printk("[module:test:2] Got request. Answering...\n");
			request_answer(obj, 42, 0);
		} else {
			printk("[module:test:2] Got message. Ignoring it.\n");
		}
	}
}

int main() {
	printk("[module:test:1] Hi world !\n");
	printk("[module:test:1] Creating new thread...\n");
	thread_new(thread2, 0);
	while (obj == -1);
	printk("[module:test:1] Object was created. Sending request...\n");
	struct user_sendrequest sr;
	sr.func = 0x80000001;
	request(obj, &sr);
	printk("[module:test:1] Got answer. Sending message...\n");
	send_msg(obj, &sr);
	printk("[module:test:1] HAHA !!! Death in 10 seconds!\n");
	thread_sleep(10000);
	return 0;
}