
Pintos Project 2 한국어 설명서 (design report) - User Program, System Call
본 내용은
"
Pintos Project 2 한국어 설명서 (design report) - User Program, System Call
"
의 원문 자료에서 일부 인용된 것입니다.
2024.06.15
문서 내 토픽
-
1. Process Execution Procedure프로젝트 2에서는 user program을 실행시키는 것이 주요 내용이다. main() 함수에서 command line을 읽어들이고 parsing한 후 run_action() 함수를 통해 실행할 프로그램을 process_execute()로 전달한다. process_execute()는 thread_create()를 호출하여 새로운 kernel thread를 생성하고, 이 thread는 start_process()를 실행한다. start_process()에서는 load() 함수를 통해 프로그램을 메모리에 로드하고, 실행을 시작한다.
-
2. System Call Procedure운영체제에는 user mode와 kernel mode가 있으며, user mode에서는 제한된 명령어만 실행할 수 있다. 따라서 user mode의 프로세스가 kernel mode의 기능을 사용하기 위해서는 system call을 호출해야 한다. system call은 user mode에서 kernel mode로 전환되어 kernel이 해당 프로세스를 실행시키고, 실행이 종료되면 다시 user mode로 돌아온다. intr_handler() 함수에서 system call 번호에 해당하는 함수를 호출하여 system call을 처리한다.
-
3. File Systemfile descriptor(fd)는 특정 file에 접근하기 위해 필요한 정수 값이며, 각 thread는 fd table을 가지고 있다. 이를 통해 fd 값으로 해당 file을 겨냥할 수 있다. inode 구조체는 file 정보를 저장하며, file_read(), file_write() 등의 함수를 통해 file에 대한 읽기/쓰기 작업을 수행한다. file_deny_write(), file_allow_write() 함수를 통해 file에 대한 쓰기 권한을 제어할 수 있다.
-
4. Process terminate messages프로세스가 종료될 때마다 프로세스의 이름과 종료 원인을 termination message로 출력하는 기능을 구현한다. 프로세스가 종료되는 경우는 프로그램 로드 실패 시와 exit system call 호출 시이다. start_process() 함수에서 load 실패 시 exit system call을 호출하도록 수정하고, exit() 함수에서 termination message를 출력하도록 구현한다.
-
5. Argument Passingcommand line에 입력된 명령어를 parsing하여 프로그램 이름과 argument를 구분하고, 이를 stack에 push하는 기능을 구현한다. process_execute() 함수에서 thread_create()에 전달하는 file_name을 parsing하여 프로그램 이름과 argument로 분리하고, start_process() 함수에서 load() 호출 전에 argument를 stack에 push한다.
-
6. System Call13가지 system call을 구현한다. 이를 위해 thread 구조체에 file descriptor table, running file 등의 멤버를 추가하고, syscall_handler() 함수에서 system call 번호에 따라 각 system call 함수를 호출한다. 각 system call 함수에서는 argument를 user stack에서 가져와 처리하고, 결과를 반환한다.
-
7. Denying Writes to Executables실행 중인 프로그램의 파일이 변경되는 것을 방지하기 위해, 프로그램을 로드할 때 file_deny_write()를 호출하여 쓰기 권한을 제한하고, 프로그램 종료 시 file_allow_write()를 호출하여 쓰기 권한을 다시 허용한다. open system call 시 실행 중인 프로그램의 파일인지 확인하여 file_deny_write()를 호출한다.
-
1. Process Execution ProcedureThe process execution procedure is a fundamental aspect of operating system design and implementation. It involves the steps taken by the operating system to load and execute a program. This includes tasks such as loading the program code and data into memory, allocating resources like CPU time and memory, and managing the execution of the program. Understanding the process execution procedure is crucial for developers and system administrators to optimize system performance, ensure process isolation, and maintain system stability. The specific steps involved may vary across different operating systems, but the general principles remain the same. Efficient process execution is essential for providing a responsive and reliable computing environment for users.
-
2. System Call ProcedureThe system call procedure is a critical component of modern operating systems, as it provides a mechanism for user-level applications to interact with the kernel and access system resources. This procedure involves the user program making a request to the operating system, which then handles the request and returns the result to the user program. The specific steps involved in the system call procedure can vary across different operating systems, but typically include the user program preparing the necessary parameters, invoking the system call, the kernel processing the request, and the kernel returning the result to the user program. Understanding the system call procedure is essential for developers who need to write applications that interact with the operating system, as well as for system administrators who need to optimize system performance and ensure the security of the system. Efficient and secure system call handling is a critical aspect of modern operating system design.
-
3. File SystemThe file system is a fundamental component of modern operating systems, providing a structured way to organize and manage data stored on storage devices. The file system procedure involves the steps taken by the operating system to create, read, write, and manage files and directories. This includes tasks such as allocating and deallocating storage space, maintaining metadata about files and directories, and providing access control mechanisms. Understanding the file system procedure is crucial for developers who need to write applications that interact with the file system, as well as for system administrators who need to manage and maintain the file system. Efficient and secure file system management is essential for ensuring the reliability and performance of the overall system. Additionally, the file system plays a critical role in data storage and retrieval, making it a key component of modern computing infrastructure.
-
4. Process terminate messagesProcess terminate messages are an important aspect of operating system design, as they provide information about the status and termination of running processes. These messages can include information such as the reason for termination (e.g., normal completion, user-initiated termination, or system-initiated termination due to an error), the exit status of the process, and any relevant error codes or diagnostic information. Understanding the process terminate messages is crucial for developers and system administrators, as it allows them to monitor the health and behavior of running processes, diagnose and troubleshoot issues, and ensure the overall stability and reliability of the system. Effective handling and interpretation of process terminate messages can also help improve the user experience by providing meaningful feedback and error messages to end-users. Overall, the process terminate messages are an essential component of modern operating system design and play a crucial role in system monitoring, troubleshooting, and maintenance.
-
5. Argument PassingArgument passing is a fundamental concept in computer programming, and it is particularly important in the context of operating systems. When a user or application invokes a system call or executes a program, the operating system needs to be able to receive and process the arguments passed to the call or program. The argument passing procedure involves the user or application preparing the necessary arguments, passing them to the operating system, and the operating system then using those arguments to execute the requested operation. Understanding the argument passing procedure is crucial for developers who need to write applications that interact with the operating system, as well as for system administrators who need to configure and manage system-level processes and services. Efficient and secure argument passing is essential for ensuring the reliability and performance of the overall system, as well as for maintaining the integrity of the operating system and its resources.
-
6. System CallThe system call is a fundamental mechanism in modern operating systems that allows user-level applications to interact with the kernel and access system resources. The system call procedure involves the user program making a request to the operating system, which then handles the request and returns the result to the user program. Understanding the system call procedure is crucial for developers who need to write applications that interact with the operating system, as well as for system administrators who need to optimize system performance and ensure the security of the system. Efficient and secure system call handling is a critical aspect of modern operating system design, as it enables applications to leverage the capabilities of the underlying hardware and software infrastructure. Additionally, the system call mechanism plays a key role in providing isolation and protection between user-level applications and the kernel, which is essential for maintaining the overall stability and reliability of the system.
-
7. Denying Writes to ExecutablesDenying writes to executable files is an important security feature in modern operating systems. This procedure involves the operating system preventing user-level applications from modifying the contents of executable files, which are typically used to store the code and instructions that are executed by the system. Preventing writes to executables helps to ensure the integrity of the system, as it protects against malicious modifications that could compromise the security or functionality of the system. Understanding the process of denying writes to executables is crucial for system administrators and security professionals who need to maintain the security and stability of the operating system. This feature is particularly important in environments where multiple users or applications may have access to the same system resources, as it helps to prevent unauthorized changes that could lead to security vulnerabilities or system instability. Overall, the ability to deny writes to executables is a critical component of modern operating system security and plays a key role in protecting the overall system from potential threats.