본문 바로가기

운영체제5

xv6 Lab: Utilities (5) xargs 이 문제는 MIT의 xv6 수업에 출처가 있습니다. 출처 : Lab: Xv6 and Unix utilities (mit.edu) Write a simple version of the UNIX xargs program: read lines from the standard input and run a command for each line, supplying the line as arguments to the command. The following example illustrates xarg's behavior: $ echo hello too | xargs echo bye bye hello too $ xargs 명령어는 어떠한 명령어의 출력을 인수로 다른 명령어를 실행시킬 때 사용한다. 이때 파이프 명령어.. 2022. 9. 3.
xv6 Lab: Utilities (4) find 이 문제는 MIT의 xv6 수업에 출처가 있습니다. 출처 : Lab: Xv6 and Unix utilities (mit.edu) Write a simple version of the UNIX find program: find all the files in a directory tree with a specific name. Your solution should be in the file user/find.c find 명령어를 구현하는 문제이다. find 명령어를 실행하면 path의 디렉토리에 들어있는 모든 파일(디렉토리 포함)을 검사하여 target과 동일한 이름을 가진 파일의 경로를 모두 출력한다. 사전 지식) 구조체 dirent struct dirent{ long d_ino; //inode 번호 of.. 2022. 9. 2.
xv6 Lab: Utilities (3) primes 이 문제는 MIT의 xv6 수업에 출처가 있습니다. 출처 : Lab: Xv6 and Unix utilities (mit.edu) Write a concurrent version of prime sieve using pipes. This idea is due to Doug McIlroy, inventor of Unix pipes. The picture halfway down this page and the surrounding text explain how to do it. Your solution should be in the file user/primes.c. 첫번째 프로세스가 2~35까지 숫자가 적힌 파이프를 만든다. 이후 소수의 배수는 소수가 아니라는 성질을 사용한다. 소수를 출력한 뒤 자식 프로세.. 2022. 9. 1.
xv6 Lab: Utilities (2) pingpong 이 문제는 MIT의 xv6 수업에 출처가 있습니다. 출처 : Lab: Xv6 and Unix utilities (mit.edu) Write a program that uses UNIX system calls to ''ping-pong'' a byte between two processes over a pair of pipes, one for each direction. The parent should send a byte to the child; the child should print ": received ping", where is its process ID, write the byte on the pipe to the parent, and exit; the parent should read the .. 2022. 8. 31.