What is System call?

이번 글에서는 System Call 과 I/O 에 대한 기본적인 개념을 정리하려고 한다.

System Call?



프로그램이 실행되는 OS 의 커널에게 요청하는 프로그래밍 방식이라고 정의할 수 있다. 하드 디스크 드라이브 또는 카메라 등 하드웨어와 관련된 요청일 수 도 있고, 새로운 프로세스를 생성하거나 실행에 대한 요청일 수 도 있고, 프로세스 스케쥴링과 같은 요청일 수 있다. 즉, 프로세스가 해당 OS 의 커널 서비스를 사용하는 것을 시스템 콜이라고 한다.


System call 의 종류는 어떤것이 있을까?

크게 6가지로 정리할 수 있다.
1. Process Control
    - create process
    - terminate process
    - load, execute
    - get/set process attributes
    - wait for time, wait event, signal event
    - allocate and free memory

    Java 를 기준으로 간단한  예시를 작성해보았다. ProcessBuilder 를 통해서 ls shell command 를 새로운 process 를 생성하여 실행하고 main process id 와 새로 생성한 process id 를 출력하고 process 를 종료하는 코드이다. 이과정에서 
    

 이외에도 현재 살아있는 모든 process 에 대한 정보를 비동기로 가져와서 출력한다.



2. File management
    - create file, delete file
    - open, close
    - read, write, reposition
    - get/set file attributes

Java 통해서 간단하게 파일을 생성하고 파일을 쓰고 읽는 코드를 작성했다.


3. Device management
    - request device, release device
    - read, write, reposition
    - get/set device attributes
    - logically attach or detach devices

4. Information maintenance
    - get/set total system information (including time, date, computer name, enterprise etc.)
    - get/set process, file, or device metadata (including author, opener, creation time and date, etc.)


5. Communication
    - create, delete communication connection
    - send, receive messages
    - transfer status information
    - attach or detach remote devices


6. Protection
    - get/set file permissions


참고


댓글

이 블로그의 인기 게시물

Spring Boot Actuator readiness, liveness probes on k8s

About Kafka Basic

sneak peek jitpack

About idempotent

About G1 GC

About ZGC

About JVM Warm up

I need to know a little JVM

HackerRank Java Between Two Sets

Java - HashMap (feat. LinkedList, Tree.. maybe Later)