SlideShare a Scribd company logo
1 of 35
Linux Internals
Core / Kernel
mailto:shayco@gmail.com
Linux Kernel Architecture
What is Linux ?
What is the Linux Kernel ?
How does the Kernel effect system
performance ?
Kernel
P
P
P P P
P
H
H H H
Kernel
Linux Kernel Architecture
Monolithic Kernel
http://en.wikipedia.org/wiki/Monolithic_kernel
Supports for System Calls
Support for Loadable Modules
Implements Preemptive Multitasking
Virtual Memory / Filesystem
Demand Paging / Loading
etc..
Linux Kernel Architecture
Kernel Function Libraries
– System (/proc, generic drivers)
– Networking (TCP, sockets, drivers)
– Storage (VFS, block devices)
– Memory (VM, PM)
– Processing (scheduler, fork, exec)
– Human Interface (HI devices)
Linux Kernel Architecture
Kernel Layers
– User space interface
– Virtual subsystem
– L2V bridge / transformer
– Logical subsystem
– Hardware interface
Linux Kernel Architecture
http://www.makelinux.net/kernel_map/
Linux Kernel and Processes
Linux Kernel and Processes
The Linux Kernel supports pre-emptive multitasking
which allows multiple processes to run individually at
the same time while prioritising these with higher
importance
What is a “Context Switch” ?
Linux Kernel and Processes
Context Switch
In order to support multi tasking a context switch
is being handled
Context switch stores or restores the CPU state
to where is 'stopped' before the last CS
Linux Kernel and Processes
Context switch can be forced by an interrupt
timer in case of a low latency operation
e.g: Disk I/O
Context Switch is also being used in order to
handle Interrupt requests
e.g: Completed read request
Linux Kernel and Processes
Context switch is being handled by the OS
Each process stack has a Process Control Block
which holds the relevant meta data for the CS
e.g: Program Counter, Registers Address List
Some CPUs (all x86 variants included) has a
Task State Segment (TSS) which is used to store
the PCB
Linux Kernel and Processes
In case a process needs to transit to Kernel
mode (during a system call) a Mode Switch is
being initiated
Price
Context switch is the most resource consuming
task of the OS.
Linux Kernel and Processes
To review Context Switch statistics use
– 'sar -w'
– 'vmstat'
Exercise:
- Review the reciprocal relations between
User / System CPU utilization and CS
Linux Kernel and Processes
To review an individual process structure use
– 'pmap'
Exercise
- Review the structure of several processes.
Can you identify the process stack ?
Linux Kernel and Processes
CPU Scheduler
The Linux Kernel has a power full and high
performance CPU scheduler.
The CUP scheduler is designed to provide the
most appropriate amount of CPU [time]slices
– Scheduling is based on a dynamic
process priority rank
– Priority is changed to make sure no
process is 'hogging' the CUP nor starving
Linux Kernel and Processes
CPU Scheduler
– For each CPU the scheduler maintain
two priority ordered arrays for active and
expired tasks. After the active one is
done arrays are swapped
4
3
2
1
4
3
2
1
Linux Kernel and Processes
CPU Scheduler
– The scheduling policy involves assessing
the priority for each task
– There are two classifications for tasks in
terms of scheduling
• CPU bound
• I/O bound
These can be either Interactive, Batch or RT
processes
Linux Kernel and Processes
CPU Scheduler
– Process pre-emption occurs, when a
process receives a hardware interrupt
– Pre-emptive kernel, can ‘prefer’ a user
mode process over a kernel mode
process (even during an exception
handling), in order to support interactivity
Linux Kernel and Processes
CPU Scheduler
–When setting ‘nice’ value to a process, one
set a static portion of the scheduler priority
for that task
–Exercise
‘grep a /etc/services >/dev/null’
Can you ‘tune’ this command group to run
faster ?
Linux Kernel and Processes
Multi Threading
Multi Threading is being used in order to have
several processing objects within the same
process
– Each Thread is being scheduled
separately by the Kernel
– Multiple threads share the same Memory
segment
Linux Kernel and Processes
Symmetric Multi Process systems can run
threads of the same process simultaneously
Linux implements 1-1 (1 scheduling object per
thread) threading via the Native Posix Thread
Library (NTPL)
* Just like Solaris and FreeBSD
Linux Kernel and Processes
To review Threads information use
– 'ps -eLf'
Exercise
– Can you identify multi threaded
processes on your system ?
– Can you find any difference between PID
and Thread ID ?
Inter Process Communication
IPC
IPC is an implementation of techniques to
exchange data between different threads
IPC can be used internally or across a computer
network
Inter Process Communication
IPC has 4 techniques
– Message passing
– Synchronization
– Shared memory
– Remote procedure call
Inter Process Communication
Message passing
Message can be a signal or data packet
Passing can be synchronous or asynchronous
Synchronisation
Used in order to keep several threads
synchronized and able to provide the same /
parallel service(s)
Inter Process Communication
Shared memory
Simply a shared form of memory
No control from of OS side
RPC
Method of running a procedure (subroutine) on a
remote process
Inter Process Communication
IPC implementations
PIPE – pass data between hierarchy related
threads
FIFO – pass data between non-related threads
Socket – pass large amount of data. Can
implement TCP internally
Shared Memory (SHM) – share defined amount
of storage between threads
Inter Process Communication
IPC implementations
Semaphore (SEM) – shared abstract data (like a
class) used to control access on a shared
resource
Inter Process Communication
IPC
Use the following commands to review IPC
information
– 'ipcs' – Review SHM, SEM, MSG
– 'ipcrm' – clean up IPC objects
– 'rpcinfo' – Review RPC
– 'popen' – Create a PIPE
– 'mkfifo' – Create a FIFO pipe
*Try 'man ipc'
Inter Process Communication
IPC
Exercise
– Review IPC information on your system
Are there any SHMs ?
– Review RPC Services available on your system
– Create a named pipe. Try to use it to pass a
message between two processes
(e.g: bash)
Can you name any advantages of using fifo ?
Linux Kernel
Kernel Tune able parameters
Changing the kernel's behaviour when working
with processes, IPC, etc
Tune able parameters can be used via the '/proc'
filesystem or the 'syscall' command
Linux Kernel
Kernel Tune able parameters
General parameters
– 'ctrl-alt-del': sets the kernel reaction to
'ctrl-alt-del' key sequence
– 'domainname': sets machine's domain
name
– 'hostname': sets machine's host name
– 'panic': sets timer before restart after panic
– 'pid_max': sets maximum PID number
Linux Kernel
Kernel Tune able parameters
IPC parameters
– 'shmax': maximum size of shared memory
segment (bytes)
– 'shmall': total amount of shared memory
pages system wide
– 'shmmni': maximun number of shared
memory segments system wide
Linux Kernel
Kernel Tune able parameters
IPC parameters
– 'sem': holds 4 parameters
• maximum semaphores per array
• total maximum semaphores
• maximum operations per semaphore
operation call
• total maximum arrays
Linux Kernel
Kernel Tune able parameters
IPC parameters
– 'msgmni': maximun message queues
system wide
– 'msgmax': maximum size of message
(bytes)
– 'msgmnb': maximum size of queue (bytes)

More Related Content

What's hot

The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelDivye Kapoor
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequenceHoucheng Lin
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingTushar B Kute
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)shimosawa
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking ExplainedThomas Graf
 
Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Toursamrat das
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device driversHoucheng Lin
 
DPDK: Multi Architecture High Performance Packet Processing
DPDK: Multi Architecture High Performance Packet ProcessingDPDK: Multi Architecture High Performance Packet Processing
DPDK: Multi Architecture High Performance Packet ProcessingMichelle Holley
 
linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBshimosawa
 

What's hot (20)

The TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux KernelThe TCP/IP Stack in the Linux Kernel
The TCP/IP Stack in the Linux Kernel
 
Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
 
Architecture Of The Linux Kernel
Architecture Of The Linux KernelArchitecture Of The Linux Kernel
Architecture Of The Linux Kernel
 
Linux Internals - Part II
Linux Internals - Part IILinux Internals - Part II
Linux Internals - Part II
 
DPDK In Depth
DPDK In DepthDPDK In Depth
DPDK In Depth
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 
File systems for Embedded Linux
File systems for Embedded LinuxFile systems for Embedded Linux
File systems for Embedded Linux
 
Linux Networking Explained
Linux Networking ExplainedLinux Networking Explained
Linux Networking Explained
 
Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Tour
 
Character Drivers
Character DriversCharacter Drivers
Character Drivers
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
DPDK: Multi Architecture High Performance Packet Processing
DPDK: Multi Architecture High Performance Packet ProcessingDPDK: Multi Architecture High Performance Packet Processing
DPDK: Multi Architecture High Performance Packet Processing
 
linux device driver
linux device driverlinux device driver
linux device driver
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Linux-Internals-and-Networking
Linux-Internals-and-NetworkingLinux-Internals-and-Networking
Linux-Internals-and-Networking
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 

Viewers also liked

A particle filter based scheme for indoor tracking on an Android Smartphone
A particle filter based scheme for indoor tracking on an Android SmartphoneA particle filter based scheme for indoor tracking on an Android Smartphone
A particle filter based scheme for indoor tracking on an Android SmartphoneDivye Kapoor
 
Cybermania Prelims
Cybermania PrelimsCybermania Prelims
Cybermania PrelimsDivye Kapoor
 
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with VolatlityOMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with VolatlityAndrew Case
 
Rootkit 102 - Kernel-Based Rootkit
Rootkit 102 - Kernel-Based RootkitRootkit 102 - Kernel-Based Rootkit
Rootkit 102 - Kernel-Based RootkitChia-Hao Tsai
 
Kernel Recipes 2015: The stable Linux Kernel Tree - 10 years of insanity
Kernel Recipes 2015: The stable Linux Kernel Tree - 10 years of insanityKernel Recipes 2015: The stable Linux Kernel Tree - 10 years of insanity
Kernel Recipes 2015: The stable Linux Kernel Tree - 10 years of insanityAnne Nicolas
 
The TCP/IP stack in the FreeBSD kernel COSCUP 2014
The TCP/IP stack in the FreeBSD kernel COSCUP 2014The TCP/IP stack in the FreeBSD kernel COSCUP 2014
The TCP/IP stack in the FreeBSD kernel COSCUP 2014Kevin Lo
 
LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness Peter Griffin
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsDivye Kapoor
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6fisher.w.y
 
Linux Kernel Exploitation
Linux Kernel ExploitationLinux Kernel Exploitation
Linux Kernel ExploitationScio Security
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxTushar B Kute
 
了解网络
了解网络了解网络
了解网络Feng Yu
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerPriyank Kapadia
 
了解Cpu
了解Cpu了解Cpu
了解CpuFeng Yu
 
Ethernet and TCP optimizations
Ethernet and TCP optimizationsEthernet and TCP optimizations
Ethernet and TCP optimizationsJeff Squyres
 

Viewers also liked (20)

Linux Internals - Part III
Linux Internals - Part IIILinux Internals - Part III
Linux Internals - Part III
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 
A particle filter based scheme for indoor tracking on an Android Smartphone
A particle filter based scheme for indoor tracking on an Android SmartphoneA particle filter based scheme for indoor tracking on an Android Smartphone
A particle filter based scheme for indoor tracking on an Android Smartphone
 
Cybermania Prelims
Cybermania PrelimsCybermania Prelims
Cybermania Prelims
 
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with VolatlityOMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
OMFW 2012: Analyzing Linux Kernel Rootkits with Volatlity
 
Rootkit 102 - Kernel-Based Rootkit
Rootkit 102 - Kernel-Based RootkitRootkit 102 - Kernel-Based Rootkit
Rootkit 102 - Kernel-Based Rootkit
 
Cybermania Mains
Cybermania MainsCybermania Mains
Cybermania Mains
 
Linux performance
Linux performanceLinux performance
Linux performance
 
Kernel Recipes 2015: The stable Linux Kernel Tree - 10 years of insanity
Kernel Recipes 2015: The stable Linux Kernel Tree - 10 years of insanityKernel Recipes 2015: The stable Linux Kernel Tree - 10 years of insanity
Kernel Recipes 2015: The stable Linux Kernel Tree - 10 years of insanity
 
The TCP/IP stack in the FreeBSD kernel COSCUP 2014
The TCP/IP stack in the FreeBSD kernel COSCUP 2014The TCP/IP stack in the FreeBSD kernel COSCUP 2014
The TCP/IP stack in the FreeBSD kernel COSCUP 2014
 
LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness
 
The Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOsThe Linux Kernel Implementation of Pipes and FIFOs
The Linux Kernel Implementation of Pipes and FIFOs
 
Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
 
Linux Kernel Exploitation
Linux Kernel ExploitationLinux Kernel Exploitation
Linux Kernel Exploitation
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in Linux
 
了解网络
了解网络了解网络
了解网络
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
 
了解Cpu
了解Cpu了解Cpu
了解Cpu
 
The Stack Frame
The Stack FrameThe Stack Frame
The Stack Frame
 
Ethernet and TCP optimizations
Ethernet and TCP optimizationsEthernet and TCP optimizations
Ethernet and TCP optimizations
 

Similar to Linux Internals - Kernel/Core

Linux Performance Tunning Kernel
Linux Performance Tunning KernelLinux Performance Tunning Kernel
Linux Performance Tunning KernelShay Cohen
 
Linux Device Driver,LDD,
Linux Device Driver,LDD,Linux Device Driver,LDD,
Linux Device Driver,LDD,Rahul Batra
 
Runos OpenFlow Controller (eng)
Runos OpenFlow Controller (eng)Runos OpenFlow Controller (eng)
Runos OpenFlow Controller (eng)Alexander Shalimov
 
Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Boden Russell
 
Unix operating system basics
Unix operating system basicsUnix operating system basics
Unix operating system basicsSankar Suriya
 
Visual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & VirtualisationVisual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & Virtualisationwangyuanyi
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2mona_hakmy
 
Operating System 4
Operating System 4Operating System 4
Operating System 4tech2click
 
Chap1_Part2.pptx
Chap1_Part2.pptxChap1_Part2.pptx
Chap1_Part2.pptxNMohd3
 
Ospresentation 120112074429-phpapp02 (1)
Ospresentation 120112074429-phpapp02 (1)Ospresentation 120112074429-phpapp02 (1)
Ospresentation 120112074429-phpapp02 (1)Vivian Vhaves
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.pptshreesha16
 
REAL TIME OPERATING SYSTEM PART 2
REAL TIME OPERATING SYSTEM PART 2REAL TIME OPERATING SYSTEM PART 2
REAL TIME OPERATING SYSTEM PART 2Embeddedcraft Craft
 
Unix _linux_fundamentals_for_hpc-_b
Unix  _linux_fundamentals_for_hpc-_bUnix  _linux_fundamentals_for_hpc-_b
Unix _linux_fundamentals_for_hpc-_bMohammad Reza Beygi
 

Similar to Linux Internals - Kernel/Core (20)

Linux Performance Tunning Kernel
Linux Performance Tunning KernelLinux Performance Tunning Kernel
Linux Performance Tunning Kernel
 
Linux Device Driver,LDD,
Linux Device Driver,LDD,Linux Device Driver,LDD,
Linux Device Driver,LDD,
 
Runos OpenFlow Controller (eng)
Runos OpenFlow Controller (eng)Runos OpenFlow Controller (eng)
Runos OpenFlow Controller (eng)
 
Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)Realizing Linux Containers (LXC)
Realizing Linux Containers (LXC)
 
Unix operating system basics
Unix operating system basicsUnix operating system basics
Unix operating system basics
 
Visual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & VirtualisationVisual comparison of Unix-like systems & Virtualisation
Visual comparison of Unix-like systems & Virtualisation
 
Linux
LinuxLinux
Linux
 
Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2Operating System 4 1193308760782240 2
Operating System 4 1193308760782240 2
 
Operating System 4
Operating System 4Operating System 4
Operating System 4
 
ubantu ppt.pptx
ubantu ppt.pptxubantu ppt.pptx
ubantu ppt.pptx
 
Chap1_Part2.pptx
Chap1_Part2.pptxChap1_Part2.pptx
Chap1_Part2.pptx
 
Ospresentation 120112074429-phpapp02 (1)
Ospresentation 120112074429-phpapp02 (1)Ospresentation 120112074429-phpapp02 (1)
Ospresentation 120112074429-phpapp02 (1)
 
Module2 MultiThreads.ppt
Module2 MultiThreads.pptModule2 MultiThreads.ppt
Module2 MultiThreads.ppt
 
Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
 
REAL TIME OPERATING SYSTEM PART 2
REAL TIME OPERATING SYSTEM PART 2REAL TIME OPERATING SYSTEM PART 2
REAL TIME OPERATING SYSTEM PART 2
 
Advanced_OS_Unit 1 & 2.ppt
Advanced_OS_Unit 1 & 2.pptAdvanced_OS_Unit 1 & 2.ppt
Advanced_OS_Unit 1 & 2.ppt
 
Bglrsession4
Bglrsession4Bglrsession4
Bglrsession4
 
Os
OsOs
Os
 
Unix _linux_fundamentals_for_hpc-_b
Unix  _linux_fundamentals_for_hpc-_bUnix  _linux_fundamentals_for_hpc-_b
Unix _linux_fundamentals_for_hpc-_b
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
 

More from Shay Cohen

Linux Performance Tunning Memory
Linux Performance Tunning MemoryLinux Performance Tunning Memory
Linux Performance Tunning MemoryShay Cohen
 
Linux Performance Tunning introduction
Linux Performance Tunning introductionLinux Performance Tunning introduction
Linux Performance Tunning introductionShay Cohen
 
chroot and SELinux
chroot and SELinuxchroot and SELinux
chroot and SELinuxShay Cohen
 
Infra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automationInfra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automationShay Cohen
 
14 network tools
14 network tools14 network tools
14 network toolsShay Cohen
 
13 process management
13 process management13 process management
13 process managementShay Cohen
 
12 linux archiving tools
12 linux archiving tools12 linux archiving tools
12 linux archiving toolsShay Cohen
 
11 linux filesystem copy
11 linux filesystem copy11 linux filesystem copy
11 linux filesystem copyShay Cohen
 
10 finding files
10 finding files10 finding files
10 finding filesShay Cohen
 
08 text processing_tools
08 text processing_tools08 text processing_tools
08 text processing_toolsShay Cohen
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editorShay Cohen
 
06 users groups_and_permissions
06 users groups_and_permissions06 users groups_and_permissions
06 users groups_and_permissionsShay Cohen
 
05 standard io_and_pipes
05 standard io_and_pipes05 standard io_and_pipes
05 standard io_and_pipesShay Cohen
 
04 using and_configuring_bash
04 using and_configuring_bash04 using and_configuring_bash
04 using and_configuring_bashShay Cohen
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystemShay Cohen
 
02 linux desktop usage
02 linux desktop usage02 linux desktop usage
02 linux desktop usageShay Cohen
 
09 string processing_with_regex copy
09 string processing_with_regex copy09 string processing_with_regex copy
09 string processing_with_regex copyShay Cohen
 
01 linux history overview
01 linux history overview01 linux history overview
01 linux history overviewShay Cohen
 

More from Shay Cohen (18)

Linux Performance Tunning Memory
Linux Performance Tunning MemoryLinux Performance Tunning Memory
Linux Performance Tunning Memory
 
Linux Performance Tunning introduction
Linux Performance Tunning introductionLinux Performance Tunning introduction
Linux Performance Tunning introduction
 
chroot and SELinux
chroot and SELinuxchroot and SELinux
chroot and SELinux
 
Infra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automationInfra / Cont delivery - 3rd party automation
Infra / Cont delivery - 3rd party automation
 
14 network tools
14 network tools14 network tools
14 network tools
 
13 process management
13 process management13 process management
13 process management
 
12 linux archiving tools
12 linux archiving tools12 linux archiving tools
12 linux archiving tools
 
11 linux filesystem copy
11 linux filesystem copy11 linux filesystem copy
11 linux filesystem copy
 
10 finding files
10 finding files10 finding files
10 finding files
 
08 text processing_tools
08 text processing_tools08 text processing_tools
08 text processing_tools
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
 
06 users groups_and_permissions
06 users groups_and_permissions06 users groups_and_permissions
06 users groups_and_permissions
 
05 standard io_and_pipes
05 standard io_and_pipes05 standard io_and_pipes
05 standard io_and_pipes
 
04 using and_configuring_bash
04 using and_configuring_bash04 using and_configuring_bash
04 using and_configuring_bash
 
03 browsing the filesystem
03 browsing the filesystem03 browsing the filesystem
03 browsing the filesystem
 
02 linux desktop usage
02 linux desktop usage02 linux desktop usage
02 linux desktop usage
 
09 string processing_with_regex copy
09 string processing_with_regex copy09 string processing_with_regex copy
09 string processing_with_regex copy
 
01 linux history overview
01 linux history overview01 linux history overview
01 linux history overview
 

Recently uploaded

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Recently uploaded (20)

Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

Linux Internals - Kernel/Core

  • 1. Linux Internals Core / Kernel mailto:shayco@gmail.com
  • 2. Linux Kernel Architecture What is Linux ? What is the Linux Kernel ? How does the Kernel effect system performance ?
  • 4. Linux Kernel Architecture Monolithic Kernel http://en.wikipedia.org/wiki/Monolithic_kernel Supports for System Calls Support for Loadable Modules Implements Preemptive Multitasking Virtual Memory / Filesystem Demand Paging / Loading etc..
  • 5. Linux Kernel Architecture Kernel Function Libraries – System (/proc, generic drivers) – Networking (TCP, sockets, drivers) – Storage (VFS, block devices) – Memory (VM, PM) – Processing (scheduler, fork, exec) – Human Interface (HI devices)
  • 6. Linux Kernel Architecture Kernel Layers – User space interface – Virtual subsystem – L2V bridge / transformer – Logical subsystem – Hardware interface
  • 8. Linux Kernel and Processes Linux Kernel and Processes The Linux Kernel supports pre-emptive multitasking which allows multiple processes to run individually at the same time while prioritising these with higher importance What is a “Context Switch” ?
  • 9. Linux Kernel and Processes Context Switch In order to support multi tasking a context switch is being handled Context switch stores or restores the CPU state to where is 'stopped' before the last CS
  • 10. Linux Kernel and Processes Context switch can be forced by an interrupt timer in case of a low latency operation e.g: Disk I/O Context Switch is also being used in order to handle Interrupt requests e.g: Completed read request
  • 11. Linux Kernel and Processes Context switch is being handled by the OS Each process stack has a Process Control Block which holds the relevant meta data for the CS e.g: Program Counter, Registers Address List Some CPUs (all x86 variants included) has a Task State Segment (TSS) which is used to store the PCB
  • 12. Linux Kernel and Processes In case a process needs to transit to Kernel mode (during a system call) a Mode Switch is being initiated Price Context switch is the most resource consuming task of the OS.
  • 13. Linux Kernel and Processes To review Context Switch statistics use – 'sar -w' – 'vmstat' Exercise: - Review the reciprocal relations between User / System CPU utilization and CS
  • 14. Linux Kernel and Processes To review an individual process structure use – 'pmap' Exercise - Review the structure of several processes. Can you identify the process stack ?
  • 15. Linux Kernel and Processes CPU Scheduler The Linux Kernel has a power full and high performance CPU scheduler. The CUP scheduler is designed to provide the most appropriate amount of CPU [time]slices – Scheduling is based on a dynamic process priority rank – Priority is changed to make sure no process is 'hogging' the CUP nor starving
  • 16. Linux Kernel and Processes CPU Scheduler – For each CPU the scheduler maintain two priority ordered arrays for active and expired tasks. After the active one is done arrays are swapped 4 3 2 1 4 3 2 1
  • 17. Linux Kernel and Processes CPU Scheduler – The scheduling policy involves assessing the priority for each task – There are two classifications for tasks in terms of scheduling • CPU bound • I/O bound These can be either Interactive, Batch or RT processes
  • 18. Linux Kernel and Processes CPU Scheduler – Process pre-emption occurs, when a process receives a hardware interrupt – Pre-emptive kernel, can ‘prefer’ a user mode process over a kernel mode process (even during an exception handling), in order to support interactivity
  • 19. Linux Kernel and Processes CPU Scheduler –When setting ‘nice’ value to a process, one set a static portion of the scheduler priority for that task –Exercise ‘grep a /etc/services >/dev/null’ Can you ‘tune’ this command group to run faster ?
  • 20. Linux Kernel and Processes Multi Threading Multi Threading is being used in order to have several processing objects within the same process – Each Thread is being scheduled separately by the Kernel – Multiple threads share the same Memory segment
  • 21. Linux Kernel and Processes Symmetric Multi Process systems can run threads of the same process simultaneously Linux implements 1-1 (1 scheduling object per thread) threading via the Native Posix Thread Library (NTPL) * Just like Solaris and FreeBSD
  • 22. Linux Kernel and Processes To review Threads information use – 'ps -eLf' Exercise – Can you identify multi threaded processes on your system ? – Can you find any difference between PID and Thread ID ?
  • 23. Inter Process Communication IPC IPC is an implementation of techniques to exchange data between different threads IPC can be used internally or across a computer network
  • 24. Inter Process Communication IPC has 4 techniques – Message passing – Synchronization – Shared memory – Remote procedure call
  • 25. Inter Process Communication Message passing Message can be a signal or data packet Passing can be synchronous or asynchronous Synchronisation Used in order to keep several threads synchronized and able to provide the same / parallel service(s)
  • 26. Inter Process Communication Shared memory Simply a shared form of memory No control from of OS side RPC Method of running a procedure (subroutine) on a remote process
  • 27. Inter Process Communication IPC implementations PIPE – pass data between hierarchy related threads FIFO – pass data between non-related threads Socket – pass large amount of data. Can implement TCP internally Shared Memory (SHM) – share defined amount of storage between threads
  • 28. Inter Process Communication IPC implementations Semaphore (SEM) – shared abstract data (like a class) used to control access on a shared resource
  • 29. Inter Process Communication IPC Use the following commands to review IPC information – 'ipcs' – Review SHM, SEM, MSG – 'ipcrm' – clean up IPC objects – 'rpcinfo' – Review RPC – 'popen' – Create a PIPE – 'mkfifo' – Create a FIFO pipe *Try 'man ipc'
  • 30. Inter Process Communication IPC Exercise – Review IPC information on your system Are there any SHMs ? – Review RPC Services available on your system – Create a named pipe. Try to use it to pass a message between two processes (e.g: bash) Can you name any advantages of using fifo ?
  • 31. Linux Kernel Kernel Tune able parameters Changing the kernel's behaviour when working with processes, IPC, etc Tune able parameters can be used via the '/proc' filesystem or the 'syscall' command
  • 32. Linux Kernel Kernel Tune able parameters General parameters – 'ctrl-alt-del': sets the kernel reaction to 'ctrl-alt-del' key sequence – 'domainname': sets machine's domain name – 'hostname': sets machine's host name – 'panic': sets timer before restart after panic – 'pid_max': sets maximum PID number
  • 33. Linux Kernel Kernel Tune able parameters IPC parameters – 'shmax': maximum size of shared memory segment (bytes) – 'shmall': total amount of shared memory pages system wide – 'shmmni': maximun number of shared memory segments system wide
  • 34. Linux Kernel Kernel Tune able parameters IPC parameters – 'sem': holds 4 parameters • maximum semaphores per array • total maximum semaphores • maximum operations per semaphore operation call • total maximum arrays
  • 35. Linux Kernel Kernel Tune able parameters IPC parameters – 'msgmni': maximun message queues system wide – 'msgmax': maximum size of message (bytes) – 'msgmnb': maximum size of queue (bytes)