System Calls
2021. 12. 2. 15:50ㆍOperating System
System Calls
- OS에 의해 제공되는 Programming Interface
- 주로 하이 레벨(high-level)인 C나 C++로 작성
- API(Application Programming Interface)를 통해 프로그램에 접근
#include <unistd.h>
ssize_t read(int fd, void *buf, size_t count)
//return value, function name, parameters
-Example of Standard API
가장 흔한 API: Win32, POSIX API, Java API
System Call Implementation
- 숫자가 각 System Call과 연관 - system call interface는 이 숫자로 index
- system call interfaace는 os kernel에 있는 system call을 야기, 상태와 값을 리턴
- caller(호출하는 것)은 system call이 어떻게 동작하는지 알지 못한다.
- 프로그램의 실행은 user mode
- kernel 모드로 요청을 보냄 --> 이것이 바로 system call
- 하드웨어 자원이나 RAM에 접근하면 kernel mode로 변경
- task가 끝나면 다시 user mode로 --> 이런 mode 변경이 context switching
System Call Parameter Passing
System call 자체 말고 그 이상의 정보를 요구하는 경우가 있음. 방법 3가지
1. register에 직접 parameters전달
2. parameter를 main memory(block or table)에 저장, register에 그 주소를 전달 - Linux와 Solaris에서 사용하는 방법
3. program이 stack에 parameter를 push(넣어놔), OS가 stack에서 pop(꺼내)
Block이나 stack은 전달되는 parameter 개수나 길이 제한 없음
Types of System Call
Process Control
- 프로세스 생성과 종료 - create process, terminate process
- end, abort
- load, execute
- 프로세스 속성 get, set - get process attributes, set process attributes
- wait for time, wait event, wait service
- 메모리 할당과 방출 - allocate memory, free memory
- 프로세스 간 공유 데이터 접근관리를 위한 Locks
- bugs 디버거
File management
- 파일 생성 삭제 - create file, delete file
- 파일 열기 닫기 - open, close file
- 파일 일기 쓰기 위치 이동- read, write, reposition
- 파일 속성 - get and set file attributes
Device management
- 디바이스 요청 해제
- read, write, reposition
- get and set device attributes
- attach device or detach device
Information mainenance
- get and set time or data
- get and set system data
- get and set process, file, device attributes
Communication
- create, delete communication connection
- 메시지 송신, 수신
- 상태 정보 전달 - transfer status information
- 원격 장치 타부착 - attach detach remote device
Protection
- 자원 접근 통제
- get and set permission
- 사용자 접근 허락 or 거절
출처
https://pediaa.com/what-is-the-difference-between-api-and-system-call/
운영체제 9th Edition(공룡책)
'Operating System' 카테고리의 다른 글
IPC(Interprocess Communication) (0) | 2021.12.02 |
---|---|
System Program (0) | 2021.12.02 |
Operating System Service (0) | 2021.12.02 |
프로세스(Process) & 스레드(Thread) (0) | 2021.11.22 |
메모리 관리 (0) | 2021.07.29 |