proc_mgmt: implementation spawn_wait() with nohang flag
[barrelfish] / usr / tests / proc_mgmt_test / main.c
index 07e94d2..09e1ccc 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <barrelfish/barrelfish.h>
 #include <barrelfish/deferred.h>
-#include <barrelfish/proc_mgmt_client.h>
+#include <barrelfish/sys_debug.h>
 #include <barrelfish/spawn_client.h>
 #include <bench/bench.h>
 
@@ -27,9 +27,8 @@ static errval_t test_spawn(coreid_t core_id, char *argv[],
 {
        assert(ret_domain_cap != NULL);
 
-       errval_t err = proc_mgmt_spawn_program(core_id,
-                                                  "/x86_64/sbin/proc_mgmt_test",
-                                                  argv, NULL, 0, ret_domain_cap);
+       errval_t err = spawn_program(core_id, "/x86_64/sbin/proc_mgmt_test",
+                                        argv, NULL, 0, ret_domain_cap);
        if (err_is_fail(err)) {
         return err;
        }
@@ -136,9 +135,9 @@ int main(int argc, char **argv)
         } else if (strcmp("span", argv[2]) == 0) {
             // Process that spans domains
             if (disp_get_core_id() == 0) {
-                proc_mgmt_span(1);
+                spawn_span(1);
             } else {
-                proc_mgmt_span(0);
+                spawn_span(0);
             }
             while(true) {
                 event_dispatch(get_default_waitset());
@@ -163,7 +162,7 @@ int main(int argc, char **argv)
     barrelfish_usleep(5*1000*1000);
 
     printf("Killing process \n");
-       err = proc_mgmt_kill(domain_cap);
+       err = spawn_kill(domain_cap);
        if (err_is_fail(err)) {
         USER_PANIC("Failed waiting for domain \n");
        }
@@ -180,7 +179,7 @@ int main(int argc, char **argv)
     barrelfish_usleep(5*1000*1000);
 
     printf("Killing process \n");
-       err = proc_mgmt_kill(domain_cap);
+       err = spawn_kill(domain_cap);
        if (err_is_fail(err)) {
         USER_PANIC("Failed waiting for domain \n");
        }
@@ -210,7 +209,7 @@ int main(int argc, char **argv)
     
        uint8_t code;
     printf("Waiting for process on different core to finish \n");
-       err = proc_mgmt_wait(domain_cap, &code);
+       err = spawn_wait(domain_cap, &code, false);
        if (err_is_fail(err)) {
         USER_PANIC("Failed waiting for domain \n");
        }
@@ -225,12 +224,22 @@ int main(int argc, char **argv)
     barrelfish_usleep(5*1000*1000);
     
     printf("Waiting for process on same core to finish \n");
-       err = proc_mgmt_wait(domain_cap, &code);
+       err = spawn_wait(domain_cap, &code, true);
+       if (err_is_fail(err)) {
+        USER_PANIC("Failed waiting for domain \n");
+       }
+    printf("Nowait hang return code %d \n", code);
+       err = spawn_wait(domain_cap, &code, false);
        if (err_is_fail(err)) {
         USER_PANIC("Failed waiting for domain \n");
        }
     printf("Unblocked \n");
 
+       err = spawn_wait(domain_cap, &code, true);
+       if (err_is_fail(err)) {
+        USER_PANIC("Failed waiting for domain \n");
+       }
+    printf("Nowait hang return code %d \n", code);
     printf("Running benchmarks core 0 \n");
     run_benchmark_spawn(0);
     printf("Running benchmarks core 3 \n");