본문 바로가기
카테고리 없음

System call

by Success T.H.I.E.F 2021. 12. 21.

Not to be confused with System command

In computing, a system call is the programmatic way in which a computher program

requests a service from the kernel of the operating system on which it is executed.

 

System calls provide an essential interface between a process and the operating system.

 

This may include hardware-related servicesfor example, accessing a HDD or accessing the device's camera)

 

일반적인 프로그램들은 사용자 모드에서 실행되므로 커널 모드에 대한 직접적인 접근이 불가능하다. 하지만 커널에 접근할 수 없으면 사용자 모드의 프로세스들이 파일을 쓰거나 불러올 수 없고 그래픽 처리와 같은 거의 모든 작업을 할 수 없다. 따라서 커널에 요청하여 커널 모드에서 처리하고 그 결과를 사용자 모드의 프로그램에게 전달하는 것이 바로 시스템 콜이다.

작동방식 

리눅스에서의 시스템 콜 동작방식

1.user process에서 fork()시스템콜 호출 -> C라이브러리에서fork 시스템 콜의 고유번호 2를 레지스터에 저장하고  0x80인터럽트를 발생시킴

2.사용자 모드-> 커널모드로의 전환.

3.커널은 IDT에서 0X80주소에 있는 system call ()을 찾음

4..systemcall(함수에서는 호출된 시스템 콜 번호와 레지스터들을 스택에 저장하고 올바른 시스템 콜 번호인지 검사, 5.sys_call_table 에서 시스템 콜 번호에 해당하는 함수 호출

6함수 종료시 ret_from_sys_call()함수에 의해 사용자 프로레스로 리턴

 

kernel?

커널프로그은 응용소프트웨어와 컴퓨터의 하드웨어를 연결한다.

The kernel is computer program at the core of a computer's OSand has complete control over everything in the system

 

It is the portion of the operating system code that is always resident in memory, and facilitates interactions between hardware and software components.

 

 

시스템콜: