ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • xv6 (linux Init)
    CS/OS 2022. 6. 2. 14:22

    linux 설치


    Orcale VM Virtual Machine -> OS( LTS 18.04 build-essential 시에 20.04는 충돌이 난다)

     

    setting


    sudo apt-get install git wget qemu
    sudo apt install build-essential
    git clone https://github.com/mit-pdos/xv6-public.git
    sudo apt-get install gdb ( if you don't have it.. )
    cd xv6-public
    make qemu-nox CPUS=1
    #qemu exit
    Ctrl+A -> X

     

    Run


    #init.c
    
    // init: The initial user-level program
    
    #include "types.h"
    #include "stat.h"
    #include "user.h"
    #include "fcntl.h"
    
    char *argv[] = { "sh", 0 };
    
    int
    main(void)
    {
      int pid, wpid;
    
    	printf(1, "...?\n");
      if(open("console", O_RDWR) < 0){
        mknod("console", 1, 1);
        open("console", O_RDWR);
      }
      dup(0);  // stdout
      dup(0);  // stderr
    
      for(;;){
        printf(1, "init: starting sh\n");
        # 시작 시에 여기다가 추가하여 주면 됨
        printf(1, "start by uksung kim\n");
        pid = fork();
        if(pid < 0){
          printf(1, "init: fork failed\n");
          exit();
        }
        if(pid == 0){
          exec("sh", argv);
          printf(1, "init: exec sh failed\n");
          exit();
        }
        while((wpid=wait()) >= 0 && wpid != pid)
          printf(1, "zombie!\n");
      }
    }

    init.c

    'CS > OS' 카테고리의 다른 글

    8. Vitrual Memory  (0) 2022.06.23
    xv6 Test code  (0) 2022.06.02
    7.Posix thread(Pthread)  (0) 2022.05.25
    5. Process_Scheduling  (0) 2022.05.19
    XV6 - 이론 정리_2  (0) 2022.05.13

    댓글

Designed by Tistory.