OS Mode


# hardware protection


1. dual mode - user mode / kernel mode - need hardware support
2. hardware protect
protected processor register in intel **CPL(current), RPL(request), DPL(descriptor)**

> supervisor = system = monitor = kernel
> before mode
> intel real mode, protected mode


# Mode change


### 1. hardware(external) interrupt - i/O interrupt  - device interrupt
← timer intterupt

### 2. software(internal) interrupt - exception
 → exception handler

### 3. system call

# system call


→ system call handler (by system call interface - inplement of wapper funct in libc.a)

### Method
> int 0x80(vector) or sysenter
> 1. same reg to KM stack
> 2. invoke system call service routine
> 3. exit handler
> syscall_exit or sysexit

> <details><summary>
> 
> example</summary>

> 1. fork ()
> 2. fork{} in libc.a
> 3. movl 2, %eax - 2 means fork, eax is register
> 4. int 0x80(system call)
> 5. go to IDT(interrupt desciptor table)
> 6. go to kernel mode function
> 7. save all in stack
> 8. check eax to function
> 9. find sys call table that (2, fork)
> 10. do ref_from_sys_call in entry.S
> 
> </details>
> 

> ### kind

> 
> [System call](https://texonom.com/system-call-f36194e943f3498593520460b36c55aa)
> 

- process management system call
- file management system call
- file system management system call
> &system_call - handler address


# Bridge


there is breidge like north and south to control traffic

> no bridge in embedded


# VM


- hosted - up on host OS
- stand alone - up on hardware

[dual booting](https://texonom.com/dual-booting-24656ee018014e6388b841b9f579c30c)






