Blog Archive

ShareThis

Monday, January 3, 2011

printf function by Linus Torvaludus in Kernel 0.01 !

  1. static int printf(const char *fmt, ...)
  2. {
  3.         va_list args;
  4.         int i;
  5.         va_start(args, fmt);
  6.         write(1,printbuf,i=vsprintf(printbuf, fmt, args));
  7.         va_end(args);
  8.         return i;
  9. }


    Standard C libraries:





    /*
     *   NOTE!!   For any other task 'pause()' would mean we have to get a
     * signal to awaken, but task0 is the sole exception (see 'schedule()')
     * as task 0 gets activated at every idle moment (when no other tasks
     * can run). For task0 'pause()' just means we go check if some other
     * task can run, and if not we return here.
     */


    for(;;) pause();   


    Task 0 is idle process.







    The schedule( ) Function

    schedule( ) implements the scheduler. Its objective is to find a process in the runqueue list and then assign the CPU to it. It is invoked, directly or in a lazy way, by several kernel routines.




    tty is a Unix command that prints to standard output the name of the file connected to standard input. The name of the program comes from teletypewriter, abbreviated "TTY".








No comments: