system programming
DESCRIPTION
System Programming. Project #1 Concepts. Assignment #1. 간단한 쉘을 구현하라 프롬프트를 나타내고 명령어를 받아들여 프로그램을 실행시키고 프로그램의 실행이 끝나면 다시 프롬프드가 명령어를 받아들이기를 반복하는 간단한 쉘 프로그램을 작성하라 . (Hint, fork, exec, wait 등의 system call 을 활용 ) - PowerPoint PPT PresentationTRANSCRIPT
-
System ProgrammingProject #1 Concepts
-
Assignment #1 . (Hint, fork, exec, wait system call ) redirection (< , >) . (Ex, a.out > a.result a.out a.result .) pipe (|) . Unix FIFO pipe 2 . : !
Key conceptForkstdin/stdoutRedirectionPipe
-
1-0. Program vs. ProcessProgram Instruction Process program instanceOS ,
-
, ?) client ?) ,
-
1-1. fork()Processfork()ProcessProcess*. *. *. PID *. Process .
-
pid = fork();If(pid!=0) { /* section A */}else{ /* section B */}pid = fork();If(pid!=0) { /* section A */}else{ /* section B */}pid = fork();If(pid!=0) { /* section A */}else{ /* section B */}*. Parent Processfork() return value Child process id*. Child Process-fork() return value 0-process id 0
-
1-2. exec()ProcessFork()ProcessProcess*. Process !*. Exec()Process X
-
2-1. Stdin, Stdout (device) * !* OS
-
2-2. Stdin, Stdoutstdin : Standard input , stdout : Standard output , Standard . File open->read or write->close
-
3. Shell?The interface with the UNIX) bash, csh, tcsh c.f.) GUI (Graphic User Interface)stdin stdout
-
4. Redirection . .> : .< : .>> : > overwrite append . Ex) .
-
example
-
5-1. Pipeline redirection Data . Redirection . ?
-
5-2 UNIX FIFO pipemkfifoCreate named pipes
-
5-3. Filter Data wc(word count) : , , .sort : .
Filter Pipeline Redirection .
-
example
-
example
-
example
-
1-1. Adam server Sun OS 5.9 PC Linux VMWare XP . =)
-
1-2. Adam
-
2. compile
gcc filename.c a.out gcc filename.c o filename2 filename2
-
3.
: tar cvzf filename.tar.gz directory : tar xvzf filename.tar.gz
-
4-1. Makefile main.c, read.c, write.c io.h . test. gcc c main.cgcc c read.cgcc c write.cgcc main.o read.o write.c o test!! -> Makefile !!
-
4-2. Makefile cont. Makefile make directory makefile target : dependencycommandcommand Tab make clean
-
4-3. Makefile cont.test : main.o read.o write.o gcc main.o read.o write.o -o test main.o : io.h main.c gcc -c main.c read.o : io.h read.c gcc -c read.c write.o: io.h write.c gcc -c write.c clean: rm f *.o test