SlideShare a Scribd company logo
1 of 27
THE SHELLSYSTEM BOOT AND THE INIT PROCESS A presentation byArvind Krishnaa J
Topics Covered ,[object Object]
Algorithm for the Shell
Redirection of IO
Piping
Asynchronous Execution of commands
System Boot Process
Algorithm for the boot process
Init Process
Algorithm for the init process
Other types of processes
Characteristics of these processes,[object Object]
The Shell ,[object Object]
Interprets it according to a fixed set of rules.
Standard input and output for the login shell are both the terminal.
If the shell recognizes the input as an internal command(like cd, for, while and others)
Executes the command internally without creating  new processesElse Assumes that the command is the name of an         executable file
More about the SHELL ,[object Object]
such aswho grep –n include *.c ls –l Shell forks and creates a child process. It execs the program that the user specified on the command line. The shell waits until the child process exits from the command and loops back to read the next command.
SHELL Algorithm /*read command line until “end of file” */ while(read(stdin,buffer,numchars)) { /*parse command line */ if(/*command line contains & */) amper=1; else amper=0; /*for commands not part of the shell command language */ if(fork()==0) { /*redirection of IO? */ if( /*redirect output */ ) { fd=creat(newfile,fmask); close(stdout); dup(fd); close(fd); /* stdout is now redirected */ }
SHELL Algorithm if( /* piping */ ) { pipe(fildes); if(fork()==0) { /* first component of command line */ close(stdout); dup(filedes[1]); close(filedes[1]); close(filedes[0]); /* stdout now goes to pipe */ /* child process does command */ execlp(command1,command1,0); } /* 2nd command component of command line */ close(stdin); dup(filedes[0]); close(filedes[0]); close(filedes[1]); /*standard input now comes from pipe */ }
SHELL Algorithm execve(command2,command2,0); } /* parent continues over here… * waits for child to exit if required */ if(amper==0) retid=wait(&status); }
Continuing the shell algorithm ,[object Object],nroff –mm bigdocument & Shell sets an internal variable amper when it parses the ampersand character if amper is set at the end of the loop Shell does not execute wait but immediately restarts the loop and reads next command line.
Redirection of IO Child process has access to a copy of the shell command line after the fork. To redirect standard output to a file, nroff –mm bigdocument > output Child “creats” the output file specified on the command line  if creat fails the child would exit immediately else child closes its previous standard output file and dups the file descriptor of the new output file. Standard output file descriptor now refers to the redirected output file. Child process closes the file descriptor obtained from creat to conserve file descriptors for the execed program. “Similar redirection occurs for standard input and standard error files”
Piping Consider the command ls-l|wc ,[object Object]
Child then forks another process.
It and its child handle one component of the command line.

More Related Content

What's hot

Secured Mobile Application Development in Android, Blackberry & iOS
Secured Mobile Application Development in Android, Blackberry & iOSSecured Mobile Application Development in Android, Blackberry & iOS
Secured Mobile Application Development in Android, Blackberry & iOSAppin Delhi
 
Performance optimization for Android
Performance optimization for AndroidPerformance optimization for Android
Performance optimization for AndroidArslan Anwar
 
x86 Mimarisi ve Tersine Mühendislik
x86 Mimarisi ve Tersine Mühendislikx86 Mimarisi ve Tersine Mühendislik
x86 Mimarisi ve Tersine Mühendislikcanyoupwn.me
 
cloud computing:Types of virtualization
cloud computing:Types of virtualizationcloud computing:Types of virtualization
cloud computing:Types of virtualizationDr.Neeraj Kumar Pandey
 
honey pots introduction and its types
honey pots introduction and its typeshoney pots introduction and its types
honey pots introduction and its typesVishal Tandel
 
Installation et configuration d'apache tomcat
Installation et configuration d'apache tomcatInstallation et configuration d'apache tomcat
Installation et configuration d'apache tomcatManassé Achim kpaya
 
N map presentation
N map presentationN map presentation
N map presentationulirraptor
 
Modern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and TechniquesModern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and TechniquesMichael Scovetta
 
Android Storage - Vold
Android Storage - VoldAndroid Storage - Vold
Android Storage - VoldWilliam Lee
 
Virtual machines and their architecture
Virtual machines and their architectureVirtual machines and their architecture
Virtual machines and their architectureMrinmoy Dalal
 

What's hot (20)

Types of Mobile Applications
Types of Mobile ApplicationsTypes of Mobile Applications
Types of Mobile Applications
 
Honeypots
HoneypotsHoneypots
Honeypots
 
The cloud ecosystem
The cloud ecosystemThe cloud ecosystem
The cloud ecosystem
 
Secured Mobile Application Development in Android, Blackberry & iOS
Secured Mobile Application Development in Android, Blackberry & iOSSecured Mobile Application Development in Android, Blackberry & iOS
Secured Mobile Application Development in Android, Blackberry & iOS
 
Performance optimization for Android
Performance optimization for AndroidPerformance optimization for Android
Performance optimization for Android
 
x86 Mimarisi ve Tersine Mühendislik
x86 Mimarisi ve Tersine Mühendislikx86 Mimarisi ve Tersine Mühendislik
x86 Mimarisi ve Tersine Mühendislik
 
cloud computing:Types of virtualization
cloud computing:Types of virtualizationcloud computing:Types of virtualization
cloud computing:Types of virtualization
 
Virtualization in cloud computing
Virtualization in cloud computingVirtualization in cloud computing
Virtualization in cloud computing
 
Honeypot
Honeypot Honeypot
Honeypot
 
honey pots introduction and its types
honey pots introduction and its typeshoney pots introduction and its types
honey pots introduction and its types
 
Installation et configuration d'apache tomcat
Installation et configuration d'apache tomcatInstallation et configuration d'apache tomcat
Installation et configuration d'apache tomcat
 
Kali linux and hacking
Kali linux  and hackingKali linux  and hacking
Kali linux and hacking
 
N map presentation
N map presentationN map presentation
N map presentation
 
Firewalld
FirewalldFirewalld
Firewalld
 
Modern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and TechniquesModern Kernel Pool Exploitation: Attacks and Techniques
Modern Kernel Pool Exploitation: Attacks and Techniques
 
Android Booting Scenarios
Android Booting ScenariosAndroid Booting Scenarios
Android Booting Scenarios
 
Android Storage - Vold
Android Storage - VoldAndroid Storage - Vold
Android Storage - Vold
 
Application of Cloud Computing
Application of Cloud ComputingApplication of Cloud Computing
Application of Cloud Computing
 
Honeypots
HoneypotsHoneypots
Honeypots
 
Virtual machines and their architecture
Virtual machines and their architectureVirtual machines and their architecture
Virtual machines and their architecture
 

Viewers also liked

File models and file accessing models
File models and file accessing modelsFile models and file accessing models
File models and file accessing modelsishmecse13
 
Smart camera monitoring system
Smart camera monitoring systemSmart camera monitoring system
Smart camera monitoring systemArvind Krishnaa
 
Canvas Based Presentation tool - First Review
Canvas Based Presentation tool - First ReviewCanvas Based Presentation tool - First Review
Canvas Based Presentation tool - First ReviewArvind Krishnaa
 
Economics of Green Growth & National Innovation Strategies
Economics of Green Growth & National Innovation StrategiesEconomics of Green Growth & National Innovation Strategies
Economics of Green Growth & National Innovation StrategiesCambridgeIP Ltd
 
20130415 paparan deputi bidang pelayanan publik mahasiswa ui wamen
20130415 paparan deputi bidang pelayanan publik mahasiswa ui wamen20130415 paparan deputi bidang pelayanan publik mahasiswa ui wamen
20130415 paparan deputi bidang pelayanan publik mahasiswa ui wamenMohammad Subhan
 
Burns supper (3ºb 2012 13)
Burns supper (3ºb 2012 13)Burns supper (3ºb 2012 13)
Burns supper (3ºb 2012 13)Rocio Torres
 
Resume M Pitcher 2010 08 27
Resume   M Pitcher 2010 08 27Resume   M Pitcher 2010 08 27
Resume M Pitcher 2010 08 27Michael Pitcher
 
Huracan alex mty 01 jul 2010
Huracan alex mty 01 jul 2010Huracan alex mty 01 jul 2010
Huracan alex mty 01 jul 2010Daniel Oropeza
 
A day in the Life of Beaver Brook Nature Center
A day in the Life of Beaver Brook Nature CenterA day in the Life of Beaver Brook Nature Center
A day in the Life of Beaver Brook Nature Centercelestepbarr
 
NäIn Onnistut Verkossa - HSY tarjoaa vinkkejä ruokaa rippeistä -teemalla Koti...
NäIn Onnistut Verkossa - HSY tarjoaa vinkkejä ruokaa rippeistä -teemalla Koti...NäIn Onnistut Verkossa - HSY tarjoaa vinkkejä ruokaa rippeistä -teemalla Koti...
NäIn Onnistut Verkossa - HSY tarjoaa vinkkejä ruokaa rippeistä -teemalla Koti...Darwin Oy
 
Final review presentation
Final review presentationFinal review presentation
Final review presentationArvind Krishnaa
 
CambridgeIP: Case Studies Of Recent Client Engagements
CambridgeIP: Case Studies Of Recent Client EngagementsCambridgeIP: Case Studies Of Recent Client Engagements
CambridgeIP: Case Studies Of Recent Client EngagementsCambridgeIP Ltd
 
Participants List For Jsm
Participants List For JsmParticipants List For Jsm
Participants List For JsmJADE aisbl
 
Asiakkaan Kohtaaminen
Asiakkaan KohtaaminenAsiakkaan Kohtaaminen
Asiakkaan KohtaaminenDarwin Oy
 

Viewers also liked (20)

File models and file accessing models
File models and file accessing modelsFile models and file accessing models
File models and file accessing models
 
On Becoming A Marketing Tour de Force
On Becoming A Marketing Tour de Force On Becoming A Marketing Tour de Force
On Becoming A Marketing Tour de Force
 
Smart camera monitoring system
Smart camera monitoring systemSmart camera monitoring system
Smart camera monitoring system
 
Grand strategy
Grand strategyGrand strategy
Grand strategy
 
Canvas Based Presentation tool - First Review
Canvas Based Presentation tool - First ReviewCanvas Based Presentation tool - First Review
Canvas Based Presentation tool - First Review
 
Economics of Green Growth & National Innovation Strategies
Economics of Green Growth & National Innovation StrategiesEconomics of Green Growth & National Innovation Strategies
Economics of Green Growth & National Innovation Strategies
 
My Home Goodrich Global
My Home Goodrich GlobalMy Home Goodrich Global
My Home Goodrich Global
 
20130415 paparan deputi bidang pelayanan publik mahasiswa ui wamen
20130415 paparan deputi bidang pelayanan publik mahasiswa ui wamen20130415 paparan deputi bidang pelayanan publik mahasiswa ui wamen
20130415 paparan deputi bidang pelayanan publik mahasiswa ui wamen
 
Burns supper (3ºb 2012 13)
Burns supper (3ºb 2012 13)Burns supper (3ºb 2012 13)
Burns supper (3ºb 2012 13)
 
clodfoundrydoc.pdf
clodfoundrydoc.pdfclodfoundrydoc.pdf
clodfoundrydoc.pdf
 
Resume M Pitcher 2010 08 27
Resume   M Pitcher 2010 08 27Resume   M Pitcher 2010 08 27
Resume M Pitcher 2010 08 27
 
Huracan alex mty 01 jul 2010
Huracan alex mty 01 jul 2010Huracan alex mty 01 jul 2010
Huracan alex mty 01 jul 2010
 
A day in the Life of Beaver Brook Nature Center
A day in the Life of Beaver Brook Nature CenterA day in the Life of Beaver Brook Nature Center
A day in the Life of Beaver Brook Nature Center
 
NäIn Onnistut Verkossa - HSY tarjoaa vinkkejä ruokaa rippeistä -teemalla Koti...
NäIn Onnistut Verkossa - HSY tarjoaa vinkkejä ruokaa rippeistä -teemalla Koti...NäIn Onnistut Verkossa - HSY tarjoaa vinkkejä ruokaa rippeistä -teemalla Koti...
NäIn Onnistut Verkossa - HSY tarjoaa vinkkejä ruokaa rippeistä -teemalla Koti...
 
Final review presentation
Final review presentationFinal review presentation
Final review presentation
 
WWF-2014-png.pptx
WWF-2014-png.pptxWWF-2014-png.pptx
WWF-2014-png.pptx
 
CambridgeIP: Case Studies Of Recent Client Engagements
CambridgeIP: Case Studies Of Recent Client EngagementsCambridgeIP: Case Studies Of Recent Client Engagements
CambridgeIP: Case Studies Of Recent Client Engagements
 
M Pitcher Resume
M Pitcher ResumeM Pitcher Resume
M Pitcher Resume
 
Participants List For Jsm
Participants List For JsmParticipants List For Jsm
Participants List For Jsm
 
Asiakkaan Kohtaaminen
Asiakkaan KohtaaminenAsiakkaan Kohtaaminen
Asiakkaan Kohtaaminen
 

Similar to Unix Shell and System Boot Process

Similar to Unix Shell and System Boot Process (20)

Linux startup
Linux startupLinux startup
Linux startup
 
Systemcall1
Systemcall1Systemcall1
Systemcall1
 
Linux Programming
Linux ProgrammingLinux Programming
Linux Programming
 
Ch04 system administration
Ch04 system administration Ch04 system administration
Ch04 system administration
 
Ch04
Ch04Ch04
Ch04
 
What is-a-computer-process-os
What is-a-computer-process-osWhat is-a-computer-process-os
What is-a-computer-process-os
 
brief intro to Linux device drivers
brief intro to Linux device driversbrief intro to Linux device drivers
brief intro to Linux device drivers
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Your first dive into systemd!
Your first dive into systemd!Your first dive into systemd!
Your first dive into systemd!
 
Process management in linux
Process management in linuxProcess management in linux
Process management in linux
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt
 
OS_lab_file.pdf
OS_lab_file.pdfOS_lab_file.pdf
OS_lab_file.pdf
 
Linux process management
Linux process managementLinux process management
Linux process management
 
Os notes
Os notesOs notes
Os notes
 
Week 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docxWeek 11Linux InternalsProcesses, schedulingLecture o.docx
Week 11Linux InternalsProcesses, schedulingLecture o.docx
 
Linux Booting Process
Linux Booting ProcessLinux Booting Process
Linux Booting Process
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
 
Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2Tarea - 3 Actividad intermedia trabajo colaborativo 2
Tarea - 3 Actividad intermedia trabajo colaborativo 2
 
Unix Administration 2
Unix Administration 2Unix Administration 2
Unix Administration 2
 
intro unix/linux 10
intro unix/linux 10intro unix/linux 10
intro unix/linux 10
 

More from Arvind Krishnaa

Twitter Agreement Analysis
Twitter Agreement AnalysisTwitter Agreement Analysis
Twitter Agreement AnalysisArvind Krishnaa
 
Recognition of unistroke gesture sequences
Recognition of unistroke gesture sequencesRecognition of unistroke gesture sequences
Recognition of unistroke gesture sequencesArvind Krishnaa
 
Human Altruism and Cooperation
Human Altruism and CooperationHuman Altruism and Cooperation
Human Altruism and CooperationArvind Krishnaa
 
Third review presentation
Third review presentationThird review presentation
Third review presentationArvind Krishnaa
 
Second review presentation
Second review presentationSecond review presentation
Second review presentationArvind Krishnaa
 
First review presentation
First review presentationFirst review presentation
First review presentationArvind Krishnaa
 
Zeroth review presentation - eBay Turmeric / SMC
Zeroth review presentation - eBay Turmeric / SMCZeroth review presentation - eBay Turmeric / SMC
Zeroth review presentation - eBay Turmeric / SMCArvind Krishnaa
 
Canvas Based Presentation - Zeroth Review
Canvas Based Presentation - Zeroth ReviewCanvas Based Presentation - Zeroth Review
Canvas Based Presentation - Zeroth ReviewArvind Krishnaa
 
Data Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesData Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesArvind Krishnaa
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsArvind Krishnaa
 

More from Arvind Krishnaa (15)

Twitter Agreement Analysis
Twitter Agreement AnalysisTwitter Agreement Analysis
Twitter Agreement Analysis
 
Analogical thinking
Analogical thinkingAnalogical thinking
Analogical thinking
 
Recognition of unistroke gesture sequences
Recognition of unistroke gesture sequencesRecognition of unistroke gesture sequences
Recognition of unistroke gesture sequences
 
Human Altruism and Cooperation
Human Altruism and CooperationHuman Altruism and Cooperation
Human Altruism and Cooperation
 
Chowka bhara
Chowka bharaChowka bhara
Chowka bhara
 
Canscape
CanscapeCanscape
Canscape
 
Third review presentation
Third review presentationThird review presentation
Third review presentation
 
Second review presentation
Second review presentationSecond review presentation
Second review presentation
 
First review presentation
First review presentationFirst review presentation
First review presentation
 
Zeroth review presentation - eBay Turmeric / SMC
Zeroth review presentation - eBay Turmeric / SMCZeroth review presentation - eBay Turmeric / SMC
Zeroth review presentation - eBay Turmeric / SMC
 
Canvas Based Presentation - Zeroth Review
Canvas Based Presentation - Zeroth ReviewCanvas Based Presentation - Zeroth Review
Canvas Based Presentation - Zeroth Review
 
Data Binding and Data Grid View Classes
Data Binding and Data Grid View ClassesData Binding and Data Grid View Classes
Data Binding and Data Grid View Classes
 
Marine Pollution
Marine PollutionMarine Pollution
Marine Pollution
 
Multithreading Concepts
Multithreading ConceptsMultithreading Concepts
Multithreading Concepts
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 

Recently uploaded

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Unix Shell and System Boot Process

  • 1. THE SHELLSYSTEM BOOT AND THE INIT PROCESS A presentation byArvind Krishnaa J
  • 2.
  • 8. Algorithm for the boot process
  • 10. Algorithm for the init process
  • 11. Other types of processes
  • 12.
  • 13.
  • 14. Interprets it according to a fixed set of rules.
  • 15. Standard input and output for the login shell are both the terminal.
  • 16. If the shell recognizes the input as an internal command(like cd, for, while and others)
  • 17. Executes the command internally without creating new processesElse Assumes that the command is the name of an executable file
  • 18.
  • 19. such aswho grep –n include *.c ls –l Shell forks and creates a child process. It execs the program that the user specified on the command line. The shell waits until the child process exits from the command and loops back to read the next command.
  • 20. SHELL Algorithm /*read command line until “end of file” */ while(read(stdin,buffer,numchars)) { /*parse command line */ if(/*command line contains & */) amper=1; else amper=0; /*for commands not part of the shell command language */ if(fork()==0) { /*redirection of IO? */ if( /*redirect output */ ) { fd=creat(newfile,fmask); close(stdout); dup(fd); close(fd); /* stdout is now redirected */ }
  • 21. SHELL Algorithm if( /* piping */ ) { pipe(fildes); if(fork()==0) { /* first component of command line */ close(stdout); dup(filedes[1]); close(filedes[1]); close(filedes[0]); /* stdout now goes to pipe */ /* child process does command */ execlp(command1,command1,0); } /* 2nd command component of command line */ close(stdin); dup(filedes[0]); close(filedes[0]); close(filedes[1]); /*standard input now comes from pipe */ }
  • 22. SHELL Algorithm execve(command2,command2,0); } /* parent continues over here… * waits for child to exit if required */ if(amper==0) retid=wait(&status); }
  • 23.
  • 24. Redirection of IO Child process has access to a copy of the shell command line after the fork. To redirect standard output to a file, nroff –mm bigdocument > output Child “creats” the output file specified on the command line if creat fails the child would exit immediately else child closes its previous standard output file and dups the file descriptor of the new output file. Standard output file descriptor now refers to the redirected output file. Child process closes the file descriptor obtained from creat to conserve file descriptors for the execed program. “Similar redirection occurs for standard input and standard error files”
  • 25.
  • 26. Child then forks another process.
  • 27. It and its child handle one component of the command line.
  • 28. Grand child process created by second fork executes the first command line component(ls).
  • 29. It writes to the pipe, dups it and closes its standard output FD.
  • 30. The parent(wc) closes its standard input file and dups the pipe read descriptor causing it to be the standard input file descriptor.
  • 31. Closes the original pipe’s read descriptor
  • 32. Executes the second component of the original command line.Relationship of processes for ls=l|wc
  • 33.
  • 34. Output of one process goes as the input of the other process.
  • 35. Parent shell (i.e the actual shell) waits until wc exits then proceeds as usual.
  • 36. Entire command line completes when wc exits.
  • 37. Shell loops and reads the next commandRelationship of processes for ls=l|wc
  • 38.
  • 39. Administrator “boots” the system.Goal of the boot process: Get a copy of the operating system into machine memory Start executing it. It is usually done in a series of stages. Administrator may set switches on the computer console to specify the address of a special hardcoded bootstrap program Or just push a button that instructs the machine to load a bootstrap program from its microcode.
  • 40.
  • 41. Program in the boot block loads the kernel from the file system  from the file /unix
  • 42.
  • 43. start Algorithm /* proc 0 continues here */ fork kernel process; /* process 0 invokes the swapper to manage the allocation of * process address space to main memory and the swap devices. * This is an infinite loop;process 0 usually sleeps in the * loop unless there is work for it to do */ execute code for swapper algorithm; }
  • 44.
  • 45. eg., Constructs linked list of free buffers and inodes, constructs hash queues for buffers and inodes, initializes region structures , page table entries and so on.
  • 46. Then it mounts the root file system onto root (“/”) and fashions the environment for process 0
  • 47. Creating a new u area
  • 48. Initializing slot 0 in the process table
  • 49.
  • 50.
  • 51. Grows the region to its proper size and copies code from the kernel address space to the new region.
  • 52. Sets up the saved user register context, and “returns” from kernel to user mode , and executes the code it had just copied.
  • 53.
  • 54. a call to exec system call
  • 55. to execute the process /etc/init
  • 56. Process 1 calls exec and executes the program in the normal fashion.
  • 57.
  • 58. That would be complicated because
  • 59. exec would have to parse file names in kernel space, not just in user space
  • 60.
  • 61. init Algorithm while((id= wait((int *) 0)) !=-1) { /* check here if a spawned child died * consider spawning it */ /* Otherwise, just continue */ }
  • 62.
  • 63. init reads the file “/etc/inittab” for instructions about which processes to spawn.
  • 64. The above file contains
  • 65. an “id”, a state identifier(single-user, multi-user etc.,)
  • 67.
  • 68. creates a process that executes the given program specificationsFor example, it may launch the getty(get teletype) processes to monitor the terminal lines configured n a system. When a user logs in, it goes through the login procedure and execs a login shell. Meanwhile, init executes a wait system call, monitoring the death of its child processes and the death of processes “orphaned” by exiting parents Sometimes in case of essential processes init may consider to respawn it.
  • 69.
  • 70. User Processes:Most processes are user processes associated with users at a terminal
  • 71. Daemon Processes: Not associated with any users, but do system-wide functions, such as administration and control of networks, executing of time-dependent activities, line printer spooling and so on.
  • 72.
  • 73. Process 0 spawns kernel processes
  • 74. Similar to daemon processes but have greater control over their execution priorities.
  • 75. Extremely powerful since it can access kernel algorithms and data structures directly without the use of system calls.
  • 76.