Linux Kernel Space Vs User space | Linux System Internal Parts

a)What is Operating System : Application can not run directly on computer hardware, that need software. It is called Operating system. 
Rel Post -https://studentsweat.blogspot.com/2010/06/linux-kernel-important-process-kernel.html 

What are the component of the Linux? Linux Internal Parts
Linux Operating System have two parts
Kernel Space + User Space 

b)Kernel important Responsibility

1.OS kernel space : – only small amount of trusted code run with high privilege.since it is run on high privilege, if any code mismatch happens kernel panic error will occur.it facilitates interaction between H/W and S/W.init is first program run on startup.
2.Memory Management(Memory Protection):
Definition : Every program to run, it requires memory for both kernel/user space program.Kernel is responsible for allocation of memory to the process for the execution and dellocates the memory when the process is no longer needed.
control the memory access right prevent the process from accessing memory that has not be allocated(Paging/segmentation). 
3. Device Management(Handling Hardware) 
  1. Instead of placing hardware management code into every application.it has been placed device driver code in to the kernel.I/O device handling such as keyboard,mouse,mice,disk drivers,printers,USB devices,network adapter and display devices.Kernel allocate request from program to the I/O devices.(Interrupt handling,boot device drivers, system calls.) 
4.Process Scheduling 
  1. Process : simply a program in execution.The execution of a process must progress in a sequential fashion.To put it in simple terms, we write our computer programs in a text file, and when we execute this program, it becomes a process which performs all the tasks mentioned in the program. 
  2. How it will be execute -> program is loaded into memory and it becomes process. 
5.File system management 
6.TCP/IP network stack
Kernel Architecture

init fork process
Process Scheduling have following 5 stages.
  1. Regular User space – execute at lower privilege(unprivilege mode) level to protect the system from malicious program.Ex : command line,Shell, graphical application,glibc(GNU C Library), 
     what is Syscall -> Linux application/Process request resource to the Linux kernel through glibc.
    what is glibc – GNU C Library.This library provides Critical API(providing interface to communicate with other program) like POSIX,BSD.  
Why Syscall required – Most operation from user application interacting with system require permission not available at the user level process.To do this operation it is require the system call. To get the details about what are the systemcall has been used we use the command strace command.it will list out all the systemcall has been used.like write(),open(),read() 
c)Relationship between user space,glibc -> systemcall, kernel space refer below image 

Common Points 
  1. 1)When process running either it can run on user mode or kernel mode.
    If it user mode it mean CPU is running on user space,it has limited capability and is controlled by a flag in the CPU. 
  2. 2)Even through kernel memory is present .user space code not allowed to access the kernel memory by a process. 
 Built Kernel,
  1. Kernel designs differ how they manage system calls and resources. 

    d)Interrupt - (How Kernel respond to Interrupt)
        1. interrupt is input signal -> process -> indicating event that needs immediate attenditation.
        2. Interrupt that commonly used by HW devices indicate physical state has been changed. Ex : keyboard key stroke, mouse key moment ,Wireless adapter,real clock timer,network card.pciehp –PCI hot plug,i915 intel graphics card,snd_hda_intel sound card.it is asynchronously,it can happen at any time with respect to the processor clock. This interrupt we can monitor by cat \proc\interrupts
        3. Software interrupt requested by the processor itself upon executing particular instruction.it is synchronous.Ex: requesting OS interacting with device driver read and write the storage.
        4. Execution Error : software error also happens unexpectedly by program execution, like divided by zero exception thrown interupt,this will catch and handle the exception. If it is not properly handle complete system may be hang.
    Comparison between HW/SW Interrupt - https://vivadifferences.com/7-difference-between-hardware-interrupt-and-software-interrupt/




e)while monitoring we need to check following metrics 
1)CPU 2) MEMORY
  
1.CPU Load Avg is high -> program more depends on the air thematic operating 
while checking in depthAnalyze the program behavior. 
 To Check in Detail with Top Command 
  1. CPU involves in disk read and write -> i/o time is high split in (wait +Idle) 
  2. CPU involves in User CPU(non kernel program) time -> it is Desktop application will run 
  3. CPU involves in System CPU(Kernel program) time -> it is utilize kernel program(it is having separate address space compare to the user CPU TIME) 
  4. Memory utilized high -> Data transfer between Air thematic operation vs memory is high 
 NOTE: To know which process running on which CPU, choose the following field in top command press f + j (Last used CPU(p))

Post a Comment

0 Comments