6주차.key

Similar documents
UniStore

untitled

/chroot/lib/ /chroot/etc/

ABC 11장

Microsoft PowerPoint - o3.pptx

Microsoft PowerPoint - ch09_파이프 [호환 모드]

2009년 상반기 사업계획

제1장 Unix란 무엇인가?

Microsoft PowerPoint - 09-Pipe

untitled

Chap06(Interprocess Communication).PDF

PowerPoint 프레젠테이션

10주차.key

슬라이드 1

강의10

10.

Chap04(Signals and Sessions).PDF

<4D F736F F F696E74202D FC7C1B7CEBCBCBDBA20BBFDBCBAB0FA20BDC7C7E0205BC8A3C8AF20B8F0B5E55D>

2009년 상반기 사업계획

좀비프로세스 2

제9장 프로세스 제어

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode]

PCServerMgmt7

chap7.key

Sena Technologies, Inc. HelloDevice Super 1.1.0

PowerPoint 프레젠테이션

SRC PLUS 제어기 MANUAL

Figure 5.01

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

PowerPoint 프레젠테이션

untitled

제1장 Unix란 무엇인가?

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

hlogin7

02 C h a p t e r Java

2009년 상반기 사업계획

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

歯9장.PDF

PowerPoint 프레젠테이션

Microsoft PowerPoint - chap9 [호환 모드]

PowerPoint 프레젠테이션


1장. 유닉스 시스템 프로그래밍 개요

제12장 파일 입출력

Microsoft PowerPoint - chap6 [호환 모드]

rmi_박준용_final.PDF

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

슬라이드 1

Deok9_Exploit Technique

System Programming Lab

chap 5: Trees

13주-14주proc.PDF

Microsoft PowerPoint - lab14.pptx


K&R2 Reference Manual 번역본

Microsoft PowerPoint - 10_Process


ETL_project_best_practice1.ppt

Microsoft PowerPoint - RMI.ppt

hlogin2

PRO1_04E [읽기 전용]

초보자를 위한 C++


슬라이드 1

PowerPoint 프레젠테이션

Chap7.PDF

4장

untitled

C++-¿Ïº®Çؼ³10Àå

PowerPoint 프레젠테이션

Microsoft Word - KPMC-400,401 SW 사용 설명서

untitled

The Self-Managing Database : Automatic Health Monitoring and Alerting

Analyst Briefing

슬라이드 1

고급 IPC 설비



PowerPoint 프레젠테이션

2013년 1회 정보처리산업기사 실기.hwp

PowerPoint 프레젠테이션

본 강의에 들어가기 전

Microsoft PowerPoint APUE(Intro).ppt

목차 BUG 문법에맞지않는질의문수행시, 에러메시지에질의문의일부만보여주는문제를수정합니다... 3 BUG ROUND, TRUNC 함수에서 DATE 포맷 IW 를추가지원합니다... 5 BUG ROLLUP/CUBE 절을포함하는질의는 SUBQUE

T100MD+

MAX+plus II Getting Started - 무작정따라하기

ESP1ºÎ-04

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

Microsoft Word - Network Programming_NewVersion_01_.docx

1217 WebTrafMon II

MySQL-Ch10

GLHPS-D

PowerPoint 프레젠테이션

Microsoft PowerPoint APUE(File InO)

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D>

untitled

2009년 상반기 사업계획

PowerPoint 프레젠테이션

Remote UI Guide

Transcription:

6,

Process concept A program in execution Program code PCB (process control block) Program counter, registers, etc. Stack Heap Data section => global variable

Process in memory

Process state New Running Waiting Ready Terminated Zombie ( defunct) :, wait(),

Process state transition

PCB Process table, task control block Process state - running, waiting, etc. Program counter CPU registers - Scheduling - Memory - Accouting information - CPU, I/O status - ( open ),

CPU switch from process to process

Threads Single-threaded vs. multi-threaded

Process scheduling Long-term scheduling & short-term scheduling (preemption) Job queue - Ready queue (run queue) - Wait queue (device queue) - I/O

Ready queue and various I/O device queues

Representation of process scheduling ready queue Wait queue

Scheduler Long-term scheduler (or job scheduler) Ready queue Short-term scheduler (or CPU scheduler) CPU ready queue, STS I/O bound process, CPU-bound process LTS ready queue (CPU I/O)

Context switch CPU PCB Context switch overhead switch,,

Process creation => fork ) init => => fork pid X (concurrently) (wait)

Process tree in Linux init pid = 1 login pid = 8415 kthreadd pid = 2 sshd pid = 3028 bash pid = 8416 khelper pid = 6 pdflush pid = 200 sshd pid = 3610 ps pid = 9298 emacs pid = 9204 tcsch pid = 4005

Process creation fork () UNIX exec( ) fork() => exec( )

Process creation fork() #include <unistd.h> #include <stdio.h> int main() { pid_t pid; pid = fork(); if (pid > 0) printf ( I am the parent of pid=%d!\n, pid); else if (!pid) printf( I am the child!\n ); else if (pid == -1) printf( Error\n ); }

Process creation fork() => exec family #include <unistd.h> #include <stdio.h> int main() { pid_t pid; pid = fork(); if (pid == -1) printf( Error\n ); if (!pid) { const char *args[] = { vi, NULL}; int ret; ret = execvp ( vi, args); if (ret == -1) { printf( Error\n ); exit (EXIT_FAILURE); } } }

Process termination exit () wait() wait() zombile state OS abort()

Wait () #include <unistd.h> #include <string.h> #include <stdio.h> int main() { int pid; pid = fork(); if (pid == 0) { sleep(5) exit(1); } else if (pid > 0) { getchar(); } } Zombie process ps -ef grep defunct grep -v grep ps -ef grep defunct awk {print $3} xargs kill -9

Wait () #include <unistd.h> #include <string.h> #include <stdio.h> int main() { int pid; int status; pid = fork(); if (pid == 0) { sleep(5) exit(1); } else if (pid > 0) { getchar(); pid = wait(&status); } } Zombie process

Interprocess communication (IPC) Cooperating processes Information sharing, computation speed up, and synchronization Shared memory & message passing process A process B process A shared memory process B message queue m 0 m 1 m 2... m 3 kernel (a) m n kernel (b)

IPC Shared memory Producer-consumer problem Message passing IPC Pipe, Unix Domain Socket, Message Queue, Mail Box, Mail Slot

IPC - pipe #include <unistd.h> int pipe (int filedes[2]); One pipe for reading and the other for writing => half-duplex * Named pipe (stream pipe) => full-duplex parent fork child user kernel fd[0] fd[1] fd[0] fd[1] pipe

IPC - pipe #include <unistd.h> #include <stdlib.h> #include <stdio.h> int main() { int n, fd[2]; pid_t pid; char line[100]; if (pipe(fd) < 0) { perror( pipe error : ); exit(0); } if ((pid = fork()) < 0) { perror( fork error: ); exit(0); } else if (pid > 0) { close(fd[0]); write(fd[1], hello world\n, 12); } else { close(fd[1]); n = read(fd[0], line, 100); printf( Received from parent %s\n, line); } exit(0); }

Synchronization Synchronization for IPC Blocking IPC (synchronous) receive send block receive receive Non-blocking IPC (asynchronous) send receive ( ) null

Remote procedure call Linux rpcgen JAVA RMI (remote method invocation) SOAP (simple object access protocol) Python Pyro Microsoft DCOM

HW #1 fork() => exec() : 1, wait(),, 0 100 0+1+2+3+ +100 : Hello, system call : Due date: 18 April