summaryrefslogtreecommitdiff
path: root/user/progH.c
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-21 16:45:28 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-21 16:45:33 -0400
commitceb9471fed96f907e37a6ba031825c31167a8ff4 (patch)
treed98392e420b4541a6ba926ff4d8b3ebe85734580 /user/progH.c
parentupdate linker scripts (diff)
downloadcomus-ceb9471fed96f907e37a6ba031825c31167a8ff4.tar.gz
comus-ceb9471fed96f907e37a6ba031825c31167a8ff4.tar.bz2
comus-ceb9471fed96f907e37a6ba031825c31167a8ff4.zip
update userland to compile
Diffstat (limited to 'user/progH.c')
-rw-r--r--user/progH.c68
1 files changed, 0 insertions, 68 deletions
diff --git a/user/progH.c b/user/progH.c
deleted file mode 100644
index 0cef860..0000000
--- a/user/progH.c
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <common.h>
-
-/**
-** User function H: exit, fork, exec, sleep, write
-**
-** Prints its ID, then spawns 'n' children; exits before they terminate.
-**
-** Invoked as: userH x n
-** where x is the ID character
-** n is the number of children to spawn
-*/
-
-USERMAIN(main)
-{
- int32_t ret = 0; // return value
- int count = 5; // child count
- char ch = 'h'; // default character to print
- char buf[128];
- int whom;
-
- // process the argument(s)
- switch (argc) {
- case 3:
- count = str2int(argv[2], 10);
- // FALL THROUGH
- case 2:
- ch = argv[1][0];
- break;
- default:
- sprint(buf, "userH: argc %d, args: ", argc);
- cwrites(buf);
- for (int i = 0; i <= argc; ++i) {
- sprint(buf, " %s", argv[argc] ? argv[argc] : "(null)");
- cwrites(buf);
- }
- cwrites("\n");
- }
-
- // announce our presence
- swritech(ch);
-
- // we spawn user Z and then exit before it can terminate
- // userZ 'Z' 10
-
- char *argsz[] = { "userZ", "Z", "10", NULL };
-
- for (int i = 0; i < count; ++i) {
- // spawn a child
- whom = spawn(ProgZ, argsz);
-
- // our exit status is the number of failed spawn() calls
- if (whom < 0) {
- sprint(buf, "!! %c spawn() failed, returned %d\n", ch, whom);
- cwrites(buf);
- ret += 1;
- }
- }
-
- // yield the CPU so that our child(ren) can run
- sleep(0);
-
- // announce our departure
- swritech(ch);
-
- exit(ret);
-
- return (42); // shut the compiler up!
-}