Skip to content

chiehmin/OS_hw4

 
 

Repository files navigation

OS_hw4

NCTU Introduction of Operating System course (2012 Fall) homework 4 (instructor:Hank Wu)


  • You can download the homework 4 tutorial and specification document below

[Homework 4 Interaction between Process and Kernel.pdf](https://github.com/headhsu2568/OS_hw4/blob/master/Homework%204%20Interaction%20between%20Process%20and%20Kernel.pdf?raw=true)

* You can see all the examples for the homework 4 in this repository, they are...

The first example to show how to write a system call and how to call it.

You should put 'sys_sayhello.c' to the kernel source code directory and make a new kernel.
Use 'make' command can help you compile the user space program 'sayhello.c'.
Use 'make run' will compile 'sayhello.c' and then run it.

This example will show how to use 'copy_to_user' and 'copy_from_user' in the system call 'sys_sayhello2.c'

Same as exapmle 1, you should put 'sys_sayhello2.c' to the kernel source code directory and make a new kernel.
Use 'make' command to compile the user space program 'sayhello2.c'.
Use 'make run' will compile 'sayhello2.c' and then run it.

This example will show how to access 'current' variable in the system call.
The system call 'get_state' will get the user space program state.

You should put 'sys_get_state.c' to the kernel source code directory and make a new kernel.
Use 'make' command to compile the user space program 'get_state.c'.
Use 'make run' will compile 'get_state.c' and then run it.

The other example to show how to access the 'current' and 'mm' variable in the system call.
The system call will get the value of CR3.

Put 'sys_get_cr3.c' to the kernel source code directory and make a new kernel.
Use 'make' command to compile the user space program 'get_cr3.c'.
Use 'make run' will compile 'get_cr3.c' and then run it.

The example will show how to use kernel space program(e.g. a system call) to send a signal to user space program.
The first user space program 'use_signal.c' will wait for a signal. When it receives a signal, it will exit after 5 seconds.
The second user space program 'use_signal2.c' will get the pid of 'use_signal' and call the system call in 'sys_use_signal.c'.
The system call 'sys_use_signal.c' will send a signal to the prcoess with its parameter(the pid passed from the caller).

Put 'sys_use_signal.c' to the kernel source code directory and make a new kernel.
Use 'make' command to compile the user space program 'use_signal.c' and 'use_signal2.c'.
Use 'make run' will compile 'use_signal.c' and 'use_signal2.c', and then run them.

The user space program prototype for Task 1 in homework 4 .
You can download this and then implement the left part(see the comments).

The system call program prototype for Task 1 in homework 4 .
You can download this and then implement the left part(see the comments).



About

NCTU Introduction of Operating System course (2012 Fall) homework 4 (instructor:Hank Wu)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published