summaryrefslogtreecommitdiff
path: root/src/user
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-20 16:34:27 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-20 16:34:27 +0200
commit7fde5e61bc7047433bfc1f47229b72d0ccd302e7 (patch)
tree7228e9008ecffa85100ac31ee5063edc62abf41e /src/user
parentc57a919d019606c7d83fea574159f542e431c199 (diff)
downloadTCE-7fde5e61bc7047433bfc1f47229b72d0ccd302e7.tar.gz
TCE-7fde5e61bc7047433bfc1f47229b72d0ccd302e7.zip
Correected some nasty tasking bugs. Still not perfect.
Diffstat (limited to 'src/user')
-rw-r--r--src/user/app/test/main.c18
-rw-r--r--src/user/app/yosh/main.cpp27
2 files changed, 28 insertions, 17 deletions
diff --git a/src/user/app/test/main.c b/src/user/app/test/main.c
index d235c57..939a15a 100644
--- a/src/user/app/test/main.c
+++ b/src/user/app/test/main.c
@@ -1,12 +1,11 @@
#include <tce/syscall.h>
+#include <stdio.h>
-int threads = 0;
+int threads = 1;
void thread_cascade(void* d) {
int n = (int)d;
- threads ++;
-
if (d == 0) {
//printk("{#} 0 cascade element started => end\n");
printk("*");
@@ -21,6 +20,7 @@ void thread_cascade(void* d) {
}
//printk("{#} FORK + ...\n");
printk(">");
+ threads += 2;
thread_new(thread_cascade, (void*)(n - 1));
//printk("{#} FORK - ...\n");
printk("<");
@@ -32,6 +32,13 @@ void thread_cascade(void* d) {
threads--;
}
+void useless_thread(void* d) {
+ while(1) {
+ printk("~");
+ schedule();
+ }
+}
+
int main(char** args) {
char**a;
if (args != 0) {
@@ -44,13 +51,16 @@ int main(char** args) {
}
printk("(test) Creating thread cascade (total 2**5 = 32 threads)\n");
+ thread_new(useless_thread, 0);
thread_new(thread_cascade, (void*)5);
while (1) {
- thread_sleep(100);
+ schedule();
if (threads == 0) break;
}
printk("\n(test) Test process exiting. Press the super key to go to the home terminal.\n");
+ printf("(test) End.\n");
+
return 0;
}
diff --git a/src/user/app/yosh/main.cpp b/src/user/app/yosh/main.cpp
index fc9580c..160e728 100644
--- a/src/user/app/yosh/main.cpp
+++ b/src/user/app/yosh/main.cpp
@@ -167,8 +167,21 @@ int Main(String *sh_args) {
}
while (1) {
- stdio.printf("\x1b[33m %s \x1b[1m", cwd.c_str());
+ // check for background processes that may have finished
+ int p = 0;
+ while (p < bg_pr_c) {
+ int ret = libc::waitpid(bg_pr[p], 0);
+ if (ret != E_NOT_FINISHED) {
+ stdio.printf("(yosh) child (pid %i) exited with status %i\n", bg_pr[p], ret);
+ bg_pr_c--;
+ bg_pr[p] = bg_pr[bg_pr_c];
+ } else {
+ p++;
+ }
+ }
+ // show prompt
+ stdio.printf("\x1b[33m %s \x1b[1m", cwd.c_str());
String s = term->readline();
stdio.printf("\x1b[0m");
if (s.size() == 0) continue;
@@ -252,18 +265,6 @@ int Main(String *sh_args) {
}
}
}
-
- int i = 0;
- while (i < bg_pr_c) {
- int ret = libc::waitpid(bg_pr[i], 0);
- if (ret != E_NOT_FINISHED) {
- stdio.printf("(yosh) child (pid %i) exited with status %i\n", bg_pr[i], ret);
- bg_pr_c--;
- bg_pr[i] = bg_pr[bg_pr_c];
- } else {
- i++;
- }
- }
}
return 0;