summaryrefslogtreecommitdiff
path: root/src/modules/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/test')
-rw-r--r--src/modules/test/main.c61
1 files changed, 21 insertions, 40 deletions
diff --git a/src/modules/test/main.c b/src/modules/test/main.c
index 493867e..8085007 100644
--- a/src/modules/test/main.c
+++ b/src/modules/test/main.c
@@ -1,53 +1,34 @@
#include <gc/syscall.h>
#include <gc/mem.h>
-#include <gc/server.h>
-#include <gm/method.h>
-#include <gm/call.h>
-#include <gm/call/manager.h>
#include <stdlib.h>
-#define FACTOR 4
-
-struct method_ret nulhandle(struct method_data *d) {
- if (d->blocking) c_logSvc("Handling a nothing request.", LL_STATUS);
- else c_logSvc("Handling a nothing message.", LL_STATUS);
- return mr_void();
-}
-
-struct method_ret openhandle(struct method_data *d) {
- CHKSSTR(d, 0);
- printk("test.open: "); printk(d->parameters[0].p); printk("\n");
- return mr_err(-1);
-}
-
-void thread2(void* d) {
- Server *s = srv_get(0);
- srv_addHandler(s, M_NOTHING_VVVV, nulhandle);
- srv_addHandler(s, M_OPEN_OMVV, openhandle);
- while (1) {
- c_logSvc("{2} Waiting for a request on main object...", LL_STATUS);
- srv_handle(s, HA_WAIT);
- }
-}
-
void thread_cascade(void* d) {
- c_logSvc("{#} Thread cascade element started. Continuing.", LL_STATUS);
- thread_new(thread_cascade, (void*)((int)d - 1));
- c_logSvc("{#} Thread cascade element finished.", LL_STATUS);
+ int n = (int)d;
+
+ if (d == 0) {
+ printk("{#} 0 cascade element started => end\n");
+ } else {
+ if (n < 0) {
+ printk("{#} - cascade element started\n");
+ n = 0 - n;
+ } else {
+ printk("{#} + cascade element started\n");
+ }
+ printk("{#} FORK + ...\n");
+ thread_new(thread_cascade, (void*)(n - 1));
+ printk("{#} FORK - ...\n");
+ thread_new(thread_cascade, (void*)(1 - n));
+ printk("{#} Thread cascade element finished.\n");
+ }
}
int main() {
- c_logSvc("Hi world from unregistered test module !", LL_NOTICE);
- c_registerSvc("test");
- c_logSvc("Creating new thread...", LL_STATUS);
- thread_new(thread2, 0);
- c_logSvc("{1} Sending a test message to manager", LL_STATUS);
- c_nothing(1, 0);
+ printk("Hi world from unregistered test module !\n");
- c_logSvc("{1} Creating thread cascade len:3", LL_STATUS);
- thread_new(thread_cascade, (void*)3);
+ printk("{1} Creating thread cascade len:1\n");
+ thread_new(thread_cascade, (void*)1);
- c_logSvc("{1} Thread now sleeping...", LL_WARNING);
+ printk("{1} Thread now sleeping...\n");
while (1) thread_sleep(1000);
return 0;
}