summaryrefslogtreecommitdiff
path: root/src/kernel/task
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-19 09:23:48 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-19 09:23:48 +0200
commit7b466345af0d3a7dc5622617ce443a90c64e34a4 (patch)
treef276b6bf391ccfe8ec3a2cb62a7f70964249621f /src/kernel/task
parentac10c1a29c44b0cb29960cd0f792c7361bc430ce (diff)
downloadTCE-7b466345af0d3a7dc5622617ce443a90c64e34a4.tar.gz
TCE-7b466345af0d3a7dc5622617ce443a90c64e34a4.zip
Added ANSI support, minimal readline-like library.
Diffstat (limited to 'src/kernel/task')
-rw-r--r--src/kernel/task/syscall.cpp4
-rw-r--r--src/kernel/task/task.cpp15
-rw-r--r--src/kernel/task/task.h5
3 files changed, 15 insertions, 9 deletions
diff --git a/src/kernel/task/syscall.cpp b/src/kernel/task/syscall.cpp
index 4eddb61..9e7c089 100644
--- a/src/kernel/task/syscall.cpp
+++ b/src/kernel/task/syscall.cpp
@@ -28,7 +28,7 @@ CALL1V(idt_waitIrq, irq_wait_sc);
CALL0(proc_priv, proc_priv_sc);
CALL1(process_sbrk, proc_sbrk_sc);
CALL1V(process_brk, proc_brk_sc);
-CALL1(process_waitpid, waitpid_sc);
+CALL2(process_waitpid, waitpid_sc);
CALL1V(close, close_sc);
@@ -43,7 +43,7 @@ static void thread_new_sc(registers* r) {
}
static void run_sc(registers *r) {
- r->eax = process_run((char*)r->ebx, (char**)r->ecx);
+ r->eax = process_run((char*)r->ebx, (char**)r->ecx, (int)r->edx);
}
static void open_sc(registers *r) {
diff --git a/src/kernel/task/task.cpp b/src/kernel/task/task.cpp
index 98204d6..7eb2b36 100644
--- a/src/kernel/task/task.cpp
+++ b/src/kernel/task/task.cpp
@@ -295,8 +295,6 @@ process::process(process* _parent, uint32_t _uid, uint32_t _privilege) : fd(12,
data = 0;
dataseg = 0;
- fd.add((node*)-1); // descriptor #0 must not be used
-
stack = 0;
if (privilege >= PL_USER) { //We are running in user mode
size_t stacksBottom = K_HIGHHALF_ADDR - 0x01000000;
@@ -431,7 +429,7 @@ void process_brk(size_t ptr) {
current_process->sbrk(ptr - current_process->data);
}
-int process_run(char* file, char** args) {
+int process_run(char* file, char** args, FILE zero_fd) {
node* bin = vfs_find(root, file);
if (bin == 0) return E_NOT_FOUND;
if ((bin->type & FT_FILE) == 0) return E_INVALID;
@@ -467,14 +465,21 @@ int process_run(char* file, char** args) {
kfree(v);
for (int i = 0; arg_data[i] != 0; i++) kfree(arg_data[i]);
kfree(arg_data);
- return (p == 0 ? E_INVALID : p->pid);
+ if (p == 0) {
+ return E_INVALID;
+ } else {
+ p->fd.set(0, current_process->fd.at((zero_fd < 0 ? 0 : zero_fd)));
+ return p->pid;
+ }
}
-int process_waitpid(int pid) {
+int process_waitpid(int pid, int block) {
if (pid <= 0) return E_INVALID_RANGE;
process *p = proc_by_pid->at(pid);
if (p != 0) {
+ if (block == 0) return E_NOT_FINISHED;
+
current_thread->queue_next = p->threads_waiting;
p->threads_waiting = current_thread;
thread_goInactive();
diff --git a/src/kernel/task/task.h b/src/kernel/task/task.h
index 2ebb66e..8a0e94a 100644
--- a/src/kernel/task/task.h
+++ b/src/kernel/task/task.h
@@ -6,6 +6,7 @@
#include "idt.h"
#include <lib/earray.h>
+#include <tce/vfs.h>
#define TS_RUNNING 0
#define TS_WAKEWAIT 2 //Waiting to be waked up by something precise (thread currently blocked)
@@ -82,7 +83,7 @@ void thread_exit();
void process_exit(size_t retval);
size_t process_sbrk(size_t size);
void process_brk(size_t ptr);
-int process_run(char* file, char** args);
-int process_waitpid(int pid);
+int process_run(char* file, char** args, FILE zero_fd);
+int process_waitpid(int pid, int block);
#endif