Timers SleepingAllows a process (or thread) to suspend execution for a period of timesleep(), nanosleep(), clock_nanosleep()TimerAllows a process to schedule a notification for itself to occur at some time in the futurealarm() → 주기적인 타이머를 사용하기에는 부적합Interval timer (itimer)POSIX timer Interval Timers int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)Provide more cont..
[학교 수업]/[학교 수업] 시스템 프로그래밍
Low resolution sleeping unsigned int sleep(unsigned int seconds)Puts the invoking process to sleep for the number of seconds specified by secondsReturn valueNumber of seconds not slept (does not set errno)A seccessful call returns 0, but the function may return other values between 0 and secondsA signal interrupt the napIf sleeping the entire specified time is truly a concern (not a usual case):..
Time Wall time (real time)Actual time and data in the real worldUsed when interfacing with the user or timestamping an eventIdeal for measuring absolute timeE.g., Noon on 1 March 1919실제 세상의 시간정보입니다Monotonic timeThis time source is strictly linearly increasing이 시간은 Wall time과 달리, 선형적으로 증가하는 시간입니다 System's uptime (time since boot)Deterministic and unchangeable이 시간은 Wall time과 달리, 바뀔 수 없고, 결정적인 시간입..
stdio: Standard I/O Library Perfomance issuesAlignmentI/O performance is optimal when requests are issued on block-aligned boundaries in integer multiples of the block sizeI/O의 성능은 OS가 관리하는 block사이즈의 배수로 관리되는 buffer의 유무에 달려있습니다. 즉 buffer의 시작주소나 길이가 block size의 양수배여야 성능이 좋아집니다.Number of system callsPerformance degradation is exacerbated by the increased number of system calls required to readA si..
I/O Redirection Operators Redirecting stadard output: >Usage: command > filenameRedirects the standard output to a file rather than the screenCreates the new destination fileif the file already exists, it will be overwritten with the data in the standard output이미 내용이 있거나, 이미 존재하는 파일이라면 기존의 내용은 사라지고 새로운 내용을 덮어씁니다E.g., ls > foo.txtCauses the shell to load and execute ls program, with standard outp..
Memory mapped I/OAllows an application to map a file into memoryProgrammers can access the file directly through memory어떤 file들을 메모리 공간에 mapping시켜서 pointer들으로 접근할 수 있게 해준다. mmap void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)Maps len bytes of the object represented by the file descriptor fd, starting at offset, into memoryaddrOffers a suggestion to the kernel of whe..
File descriptorRegular filesSpecial filesCharacter devices (e.g., Keyboard)Block devicesPipesSockets우리가 평소에 다루던 진짜 file들은 Regular file들이고, Character devices나 pipe와 같은 file들을 Special file들이라 부른다. 그리고 Multiplexed I/O는 special file들에 유용하게 쓰인다. A signle process cannot reasonably block on more than one file descriptor at the same timeif a read() system call is issued, and there is not yet any data, t..
File Offset Location in the file at which the next read() or write() will commenceExpressed as an ordinal byte position relative to the start of the fileThe first byte of the file is at offset 0Set to point to the start of the file when the file is openedAutomatically adjusted by each subsequent call to read() or write()Successive read() and write() calls progress sequentially through a file Rep..