2017年2月9日 星期四

Linux Process

What is user space and kernel space?
User space is a sand box to contain the normal programs to run in its limited memory space that cannot access other part of memory so that it cannot interfere other programs and OS kernel and hence avoid crashing others.
Kernel space is that has full access to all memory and machine hardware and all system calls are run in it.

What is system call?
Linux kernel provides system calls that are functions defined in libc. Examples are syscall(), getpid(), exit(), fork(), read(), write(), open(), close(), waitpid(), time(), kill(), nice(), rename(), link(), chmod(), pause(), mkdir(), chdir(), pipe(), ipc(). There are aboub 200 system calls in Linux.

Kernal time example in c:
string s = "a"; // us
file.write(s); // sy
s = "b"; // us
us refers to user space and sy refers to system or kernal space.

How to check user space and kernel space?
Use command top
%Cpu(s): 24.8 us, 0.5 sy, 0.0 ni, 73.6 id, 0.4 wa, 0.0 hi, 0.2 si, 0.0 st
24 % in user space, 0.5 % is system or kernel space, 0% in niceness nice process, 73% idle, 0.4% wait for IO without calculating other things, 0% in hardware interrupt, 0% in software interrupt, 0% in stole time stolen by other virtual machine.

沒有留言:

張貼留言

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...