

{"id":99909,"date":"2021-08-03T09:00:21","date_gmt":"2021-08-03T03:30:21","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=99909"},"modified":"2021-07-30T14:46:44","modified_gmt":"2021-07-30T09:16:44","slug":"processes-in-operating-system","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/","title":{"rendered":"Processes in Operating System"},"content":{"rendered":"<p>The program being executed by an operating system is a process. It takes place in a sequence and is the basic unit of work to be implemented in the system. A program during execution becomes a process and performs all the tasks for the user.<\/p>\n<h3>Sections of a Process in OS<\/h3>\n<p>A process has four sections. These sections are as follows:<\/p>\n<p><strong>1. Stack:<\/strong> This has temporary data like return address and local variables.<\/p>\n<p><strong>2. Heap:<\/strong> This is the memory allocated to a process dynamically, during its run time.<\/p>\n<p><strong>3. Text:<\/strong> This consists of the ongoing activity of a process that is represented by the value of the Program Counter and the contents of the processor&#8217;s registers.<\/p>\n<p><strong>4. Data:<\/strong> This has global and static variables.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/PROCESSES-IN-OS-Sections-of-a-process.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99920\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/PROCESSES-IN-OS-Sections-of-a-process.jpg\" alt=\"Sections of a process in OS\" width=\"346\" height=\"453\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/PROCESSES-IN-OS-Sections-of-a-process.jpg 346w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/PROCESSES-IN-OS-Sections-of-a-process-320x419.jpg 320w\" sizes=\"auto, (max-width: 346px) 100vw, 346px\" \/><\/a><\/p>\n<h3>Different times concerning a process in Operating System<\/h3>\n<p><strong>1. Burst time:<\/strong> The time required for the execution of the process<\/p>\n<p><strong>2. Arrival time:<\/strong> The time at which the process enters the ready queue.<\/p>\n<p><strong>3. Turnaround time:<\/strong> The time taken by a process from entering the ready state for the first time till its exit time i.e., the difference between completion time and arrival time.<\/p>\n<p><strong>4. Waiting time:<\/strong> The time spent by the process in ready state i.e., the difference between turnaround time and burst time.<\/p>\n<p><strong>5. Exit time:<\/strong> The time at which the process completes execution and exits the system.<\/p>\n<p><strong>6. Response time:<\/strong> The time taken by a process, to be allocated to the CPU, for the first time after entering ready queue i.e., the difference between the time a process first gets CPU and the arrival time<\/p>\n<p><strong>7. Throughput:<\/strong> This is a way to find the efficiency of a processor. It is the number of processes executed by the CPU in a given amount of time.<\/p>\n<h3>Program<\/h3>\n<p>Program is a part of a code. It can be of any length from a single line to millions of lines. A computer programmer or coder is responsible for writing a program. It is a set of instructions written to perform specific tasks for the user. Following is a simple example of a program in the C programming language:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#include &lt;stdio.h&gt;\r\n\r\nint main() {\r\n   printf(\"DataFlair \\n\");\r\n   return 0;\r\n}\r\n<\/pre>\n<p>We can say that a process is a dynamic instance of a program. The secondary storage stores a program. This program converts into a process during execution. Software is a collection of computer programs, libraries, and related data.<\/p>\n<h3>Process vs Program in OS<\/h3>\n<p>The following table shows the difference between a process and a program.<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>Process<\/strong><\/td>\n<td><strong>Program<\/strong><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">An instance of a program being executed.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">A collection of instructions written to perform a specific task for the user.\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Short lifetime<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Long lifetime<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Requires resources such as memory, CPU, I\/O devices, etc&#8230;<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Stored in hard-disk and doesn\u2019t requires any resources<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Has a dynamic instance of code and data<\/span><\/td>\n<td><span style=\"font-weight: 400;\"> Has static code and data.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Running instance of code<\/span><\/td>\n<td><span style=\"font-weight: 400;\"> Executable code<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Process Life Cycle in OS<\/h3>\n<p>During execution, a process has to go through multiple states. Though these states and their names differ in different operating systems, the following are the common states of the process life cycle:<\/p>\n<p><strong>1. Start:<\/strong> The initial state of a process when it is first created.<\/p>\n<p><strong>2. Ready:<\/strong> In this state, the process is ready to be assigned to a processor and waits for the OS to allocate the processor to it. A process can come into this state multiple times especially when the scheduler assigns the CPU to another process.<\/p>\n<p><strong>3. Running:<\/strong> After being assigned to a processor, the process enters into the running state and the processor executes its instructions.<\/p>\n<p><strong>4. Waiting:<\/strong> If another process occupies the resource required by the running process, the running process moves into a waiting state.<\/p>\n<p><strong>5. Terminated or Exit:<\/strong> A process moves to this state when an OS terminates it, or after it finishes execution and waits to be removed from the main memory.<\/p>\n<h3>Process Control Block (PCB) in OS<\/h3>\n<p>A data structure retained by the OS for each process is known as a process control block. Each PCB has its own integer process ID (PID) which is the identity of the PCB. PCB is a collection of all the information regarding a process like the state of the process, location of a process, etc. The lifetime of a PCB is as long as that of a process i.e., till the OS terminates a process.<\/p>\n<p>Following is the information that PCB keeps a track of:<\/p>\n<p><strong>1. Process State:<\/strong> This is the current state of the process. It can be any state then, ready, running, waiting, or any else.<\/p>\n<p><strong>2. Process privileges:<\/strong> This allows\/disallows access to system resources.<\/p>\n<p><strong>3. Process ID:<\/strong> This is the unique identification of a process like aadhar card for us.<\/p>\n<p><strong>4. Pointer:<\/strong> It is a pointer to the parent process.<\/p>\n<p><strong>5. Program Counter:<\/strong> This points to the address of the next instruction that is to be executed for a process.<\/p>\n<p><strong>6. CPU registers:<\/strong> This is where a process is stored before execution or entering the running state.<\/p>\n<p><strong>7. CPU Scheduling Information:<\/strong> Stores process priority and other scheduling information necessary for scheduling a process.<\/p>\n<p><strong>8. Memory management information:<\/strong> This contains page table information, memory limits, and segment table based on the memory used by the operating system.<\/p>\n<p><strong>9. Accounting information:<\/strong> Stores information regarding the amount of times a processor is used for process execution, time limits, execution ID, etc.<\/p>\n<p><strong>10. I\/O status information:<\/strong> The list of I\/O devices allocated to the process is stored here.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Process-Control-Block-PCB.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-99921\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Process-Control-Block-PCB.jpg\" alt=\"Process Control Block (PCB) in OS\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Process-Control-Block-PCB.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Process-Control-Block-PCB-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Process-Control-Block-PCB-720x377.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Process-Control-Block-PCB-520x272.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Process-Control-Block-PCB-320x167.jpg 320w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h3>CPU-Bound vs I\/O-Bound Processes<\/h3>\n<p>The process of CPU-bound needs more CPU time i.e., it spends more time in the running state. Whereas the process of I\/O-bound needs more I\/O time and less CPU time i.e., it spends more time in the waiting state.<\/p>\n<h3>Process Scheduling in OS<\/h3>\n<p>A process is the basis of computation. A process is a lot more than a program code. It is a program in execution. A process has four sections, namely, text, data, heap, and stack. We will discuss process scheduling and its types in detail in the next segment.<\/p>\n<h3>Summary<\/h3>\n<p>A process is an instance of a running program. There are four sections of a process stack, heap, text, and data. There are five states in a process, namely, new, ready, running, waiting, and termination. Every process has its own PCB that keeps track of all the information related to a process like a process ID, process state, pointer, priority, program counter, CPU register, I\/O information, accounting information, and much more.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The program being executed by an operating system is a process. It takes place in a sequence and is the basic unit of work to be implemented in the system. A program during execution&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":99919,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24565],"tags":[24885,24883,24884,24888,24887,24886,24882],"class_list":["post-99909","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-operating-system-tutorials","tag-cpu-bound-vs-i-o-bound-processes","tag-operating-system-processes","tag-process-control-block-in-os","tag-process-in-os","tag-process-life-cycle","tag-process-scheduling-in-os","tag-processes-in-operating-system"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Processes in Operating System - DataFlair<\/title>\n<meta name=\"description\" content=\"Process in OS is an instance of a running program. See the sections and life cycle of Processes in Operating System.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Processes in Operating System - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Process in OS is an instance of a running program. See the sections and life cycle of Processes in Operating System.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-03T03:30:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Processes-in-Operating-System.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Processes in Operating System - DataFlair","description":"Process in OS is an instance of a running program. See the sections and life cycle of Processes in Operating System.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/","og_locale":"en_US","og_type":"article","og_title":"Processes in Operating System - DataFlair","og_description":"Process in OS is an instance of a running program. See the sections and life cycle of Processes in Operating System.","og_url":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2021-08-03T03:30:21+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Processes-in-Operating-System.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9"},"headline":"Processes in Operating System","datePublished":"2021-08-03T03:30:21+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/"},"wordCount":1058,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Processes-in-Operating-System.jpg","keywords":["CPU-Bound vs I\/O-Bound Processes","operating system processes","Process Control Block in OS","Process in OS","Process Life Cycle","Process Scheduling in OS","Processes in Operating System"],"articleSection":["Operating System Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/","url":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/","name":"Processes in Operating System - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Processes-in-Operating-System.jpg","datePublished":"2021-08-03T03:30:21+00:00","description":"Process in OS is an instance of a running program. See the sections and life cycle of Processes in Operating System.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Processes-in-Operating-System.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/07\/Processes-in-Operating-System.jpg","width":1200,"height":628,"caption":"Processes in Operating System"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/processes-in-operating-system\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Operating System Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/operating-system-tutorials\/"},{"@type":"ListItem","position":3,"name":"Processes in Operating System"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team is a group of passionate educators and industry experts dedicated to providing high-quality online learning resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With years of experience in the field, the team aims to simplify complex topics and help learners advance their careers. At DataFlair, we believe in empowering students and professionals with the knowledge and skills needed to thrive in today\u2019s fast-paced tech industry. Follow us for Free courses, expert insights, tutorials, and practical tips to boost your learning journey.","url":"https:\/\/data-flair.training\/blogs\/author\/datafbdad\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/99909","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=99909"}],"version-history":[{"count":2,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/99909\/revisions"}],"predecessor-version":[{"id":99922,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/99909\/revisions\/99922"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/99919"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=99909"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=99909"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=99909"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}