Xv6 with picoc & Linkage editor  v1.0
The project delineate mutual cohesion between c library, linkage editor ( linker), interpreter and operating system by porting the same on xv6 kernel
init.c
00001 // init: The initial user-level program
00002 
00003 #include "types.h"
00004 #include "stat.h"
00005 #include "user.h"
00006 #include "fcntl.h"
00007 
00008 char *argv[] = { "sh", 0 };
00009 
00010 int
00011 main(void)
00012 {
00013   int pid, wpid;
00014 
00015   if(open("console", O_RDWR) < 0){
00016     mknod("console", 1, 1);
00017     open("console", O_RDWR);
00018   }
00019   dup(0);  // stdout
00020   dup(0);  // stderr
00021   
00022 //  printf(1,"b4 exec\n");
00023   for(;;){
00024     printf( "init: starting sh\n");
00025     pid = fork();
00026     if(pid < 0){
00027       printf( "init: fork failed\n");
00028       exit(1);
00029     }
00030     if(pid == 0){
00031       exec("./bin/sh", argv);
00032       printf( "init: exec sh failed\n");
00033       exit(1);
00034     }
00035     while((wpid=wait()) >= 0 && wpid != pid)
00036       printf( "zombie!\n");
00037   }
00038 }
 All Data Structures