CS/System Programming

Introduction

dawonny 2022. 3. 12. 05:04
728x90
반응형
Operating System(OS)

컴퓨터 사용자와 컴퓨터 하드웨어 사이의 중개자 역할

 

Operating system 의 목표

- 컴퓨터 시스템 사용을 편리하게 한다.

- 컴퓨터 하드웨어를 효율적으로 사용한다.

 

기본 OS 개념

- Multi-use environment

여러 유저가 동시 사용하는 환경

- Process and Scheduling

여러 프로그램 동시 실행

- User space and Kernel space

여러 프로그램을 독립적으로 작동하도록 Address space를 관리하고 User 레벨과 Kernel 레벨을 별도로 관리한다

- Basic and Advanced I/O

컴퓨터 시스템의 주요 자원이 주변장치(I/O)를 통로를 제공한다.


장단점

장점

- 오픈소스 : developer versions, stabilized version, GNU spirit(copy, modification, distrubution are possible)

- Open developer site & User group(LUG) : 정보교환

- Royalty free

단점

- 버전 업그레이드가 너무 빠르다 -> 안정화가 어려움

- Less official programs : office, game, desktop 환경

- Device drivers -> 많은 개발자들이 non-mature 한 device drivers 를 개발

                     -> Hidden patents & License problems

 


Distribution, Development, Standardization

Linux distributors

- Debian : non-commercial

- Fedora : commercial

- Various other distributions

Linux archive

- http://www.kernel.org

Source navigation

- http://lxr.free-electrons.com/ 

 


Computter System Overview

하드웨어 -> CPU, Memory, I/O Devices

System Call 이 OS에 기능을 요청한다.


Layered Linux Structure

OS 종류 중 하나인 Linux 의 구조

kernel 이 핵심 역할이다.

 

 

 

하드웨어

- CPU, Memory, Disk, Peripherals

 

Kernel

- Process management

- File management

- Memory management

- Device management

- Network management

 

System Call

- Linux kernel 에 대한 프로그래머의 기능 인터페이스

- application은 system call 을 이용해서 직접 접근 가능

- system call 을 감싼 shell, library routines 을 통해서 접근 가능

 

Commands, Utilities, Application programs

- request kernel services using library routines or system calls


System Calls vs. Library Calls

System Calls

- kernel code로 들어가는 진입점

- documented in section 2 of the linux manual(e.g. write(2) or man 2 write)

 

Library Calls

- transfers to user code which performs the desired functions.

- documented in section 3 of the linux manual(e.g. printf(3))

- API(application programming interface)라고도 불린다

 

 

Example : read() system call

read()는

System Call 을 사용,

 

fgetc(), fscanf() 는

Library Call 을 사용

 

 

 

 

 

 

 


System Calls by Processes


Linux System Calls Overview

File descriptor I/O

- open(); close(); creat(), read(); write();

- seek(); // random access

- fcntl(); // for file/record locking

 

Process control 

- fork(); exec(); wait(); exit();

 

Thread programming

- pthread_...();

 

IPC 프로세스들간의 통신(상호작용)

- Pipe: pipe(); read(); write(); close();

- Message queue: …

 

Signal handling

- signal(); kill(); // making signal handlers;

- alarm(); pause(); sigpause(); sigblock(); sigsuspend();

- itimer (interval timer) // timer creation & handling

 

Memory management

- malloc(); free(); memcpy(); bzero();

- Memory mapped files: mmap(); munmap();

 

Synchronization

- File lock/unlock with fcntl()

- Semaphores (POSIX, SysV)

 

Time management

- Epoch time, calendar time managements

 

Network socket API (TCP, UDP) 

- socket(); close();

- bind(); listen();

- accept(); connect();

- send() recv(); // TCP

- sendto(); recvfrom(); // UCP


 

728x90
반응형