From 8e933fac9fd068343bb602f13175c8d70a6c5768 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Wed, 1 Aug 2018 02:27:57 +1000 Subject: Defined EOF as -1 in stdio.h. Implemented the sprintf() library function in lib/stdio.c which uses the vsprintf() function. Implemented a very primative controlling TTY for each process. This is achieved by a switch in the sys_puts system call which uses the 'ctty' element of the process' task structure to determine an appropriate I/O channel. A negative ctty value doesn't equate to any I/O channel effectively disabling the process' output. Added the sys_ctty system call which allows a process to set it's own ctty value. Removed the sys_rsputs system call. Output to serial is now performed by the process first setting it's ctty value to 1, then invoking sys_puts. --- usrbin/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'usrbin') diff --git a/usrbin/main.c b/usrbin/main.c index 8c8d2dc..68f1a5c 100644 --- a/usrbin/main.c +++ b/usrbin/main.c @@ -9,6 +9,8 @@ void sighandler(int sig) { } void pid1(void) { + printf("We did it ma!\n"); + signal(SIGALRM, &sighandler); alarm(2); pause(); @@ -22,6 +24,8 @@ void pid1(void) { void pid2(void) { int x = 0; + printf("We did it ma!\n"); + while(1) { sleep(1); printf("0x%04x:0x%08x: 0x%08x, 0x%08x\n", getpid(), (uint32_t) getpdir(), time(), x++); @@ -29,9 +33,10 @@ void pid2(void) { } void main(void) { - printf("We did it ma!\n"); - - if(getpid() == 1) + if(getpid() == 1) { + ctty(1); pid1(); + } + pid2(); } -- cgit v1.3