

{"id":100323,"date":"2021-08-24T09:00:00","date_gmt":"2021-08-24T03:30:00","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=100323"},"modified":"2021-08-18T18:49:17","modified_gmt":"2021-08-18T13:19:17","slug":"system-call-in-os","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/","title":{"rendered":"System Call in OS"},"content":{"rendered":"<p>We use system calls to provide an interface between a process and OS. A system call helps a program request services from the kernel. It is a programmatic method and the only entry point for the kernel system. These services are offered with the help of an API (Application Programming Interface).<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Introduction-to-System-Call.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-100356\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Introduction-to-System-Call.jpg\" alt=\"Introduction to System Call\" width=\"720\" height=\"659\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Introduction-to-System-Call.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Introduction-to-System-Call-520x476.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Introduction-to-System-Call-320x293.jpg 320w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<h3>Workings of a System Call in OS<\/h3>\n<p>Following are the steps on how a System Call works:<br \/>\n<strong>Step 1:<\/strong> The processor executes a process in the user mode until a system call interrupts it.<br \/>\n<strong>Step 2:<\/strong> Then on a priority basis, the system call is executed in the kernel mode.<br \/>\n<strong>Step 3:<\/strong> After the completion of system call execution, control returns to user mode.,<br \/>\n<strong>Step 4:<\/strong> The execution resumes in Kernel mode.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Workings-of-a-System-Call.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-100357\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Workings-of-a-System-Call.jpg\" alt=\"Workings of a System Call in OS\" width=\"798\" height=\"554\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Workings-of-a-System-Call.jpg 798w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Workings-of-a-System-Call-768x533.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Workings-of-a-System-Call-720x500.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Workings-of-a-System-Call-520x361.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/Workings-of-a-System-Call-320x222.jpg 320w\" sizes=\"auto, (max-width: 798px) 100vw, 798px\" \/><\/a><\/p>\n<h3>Need for System Calls<\/h3>\n<p>Following are the reasons we need system calls:<\/p>\n<ul>\n<li>To read and write from files.<\/li>\n<li>To create or delete files.<\/li>\n<li>To create and manage new processes.<\/li>\n<li>To send and receive packets, through network connections.<\/li>\n<li>To access hardware devices.<\/li>\n<\/ul>\n<h3>Services of System Call in Operating System<\/h3>\n<p>Following are the services provided by a system call:<\/p>\n<ul>\n<li>Manages main memory<\/li>\n<li>Helps access files and directories and manages the file system.<\/li>\n<li>Creates and manages new processes<\/li>\n<li>I\/O device handling<\/li>\n<li>Provides system protection<\/li>\n<\/ul>\n<h3>Types of System calls in Operating System<\/h3>\n<p>The five types of System Calls are:<\/p>\n<h4>1. Process Control<\/h4>\n<p>It performs the tasks of process creation, process termination, etc.<\/p>\n<p><strong>Functions of process Control:<\/strong><\/p>\n<ul>\n<li>End and Abort<\/li>\n<li>Loading and Execution of a process<\/li>\n<li>Creation and termination of a Process<\/li>\n<li>Wait and Signal Event<\/li>\n<li>Allocation of free memory<\/li>\n<\/ul>\n<h4>2. File Management<\/h4>\n<p>It handles jobs regarding file manipulation.<\/p>\n<p><strong>Functions of File Management:<\/strong><\/p>\n<ul>\n<li>Creation of a file<\/li>\n<li>Deletion of a file<\/li>\n<li>Opening and closing of a file<\/li>\n<li>Reading, writing, and repositioning<\/li>\n<li>Getting and setting file attributes<\/li>\n<\/ul>\n<h4>3. Device Management<\/h4>\n<p>It helps in device manipulation like reading from device buffers, writing into device buffers, etc.<\/p>\n<p><strong>Functions of Device Management:<\/strong><\/p>\n<ul>\n<li>Requesting and releasing devices<\/li>\n<li>Attaching and detaching devices logically<\/li>\n<li>Getting and setting device attributes<\/li>\n<\/ul>\n<h4>4. Information Maintenance<\/h4>\n<p>It handles information and information transfer between OS and the user program.<\/p>\n<p><strong>Functions of Information maintenance:<\/strong><\/p>\n<ul>\n<li>Getting or setting time and date<\/li>\n<li>Getting process and device attributes<\/li>\n<\/ul>\n<h4>5. Communication<\/h4>\n<p>This is for interprocess communications.<\/p>\n<p><strong>Functions of interprocess communication:<\/strong><\/p>\n<ul>\n<li>Creation and deletion of communications connections<\/li>\n<li>Sending and receiving messages<\/li>\n<li>Helping OS transfer status information<\/li>\n<li>Attaching or detaching remote devices<\/li>\n<\/ul>\n<h3>Rules for passing Parameters for System Call<\/h3>\n<p>Following are the rules for passing parameters to the System Call:<\/p>\n<ul>\n<li>The OS pushes on or pops parameters off the stack.<\/li>\n<li>We can pass parameters in registers.<\/li>\n<li>In case parameters are more than registers, they are stored in a block. The block address is passed as a parameter to a register.<\/li>\n<\/ul>\n<h3>Important System Calls Used in OS<\/h3>\n<p>Following are the important system calls used in an OS:<\/p>\n<h4>1. wait()<\/h4>\n<p>When a process is running, the rest of the processes stay in the waiting state and wait for their turn. This happens when a parent process creates a child process, and the parent process suspends until the child process is done executing. This suspension of the parent process occurs automatically with the help of the wait() system call. Control moves back to the parent process after the child process ends execution.<\/p>\n<h4>2. fork()<\/h4>\n<p>This system call allows a process to create copy processes of itself. A parent process creates a child process. This suspends the execution of the parent process until the child process executes.<\/p>\n<h4>3. exec()<\/h4>\n<p>This system call runs when an executable file replaces the older one when the process is still running. Though the original process identifier still remains as the old process is still executing, the new process replaces things like a stack, data, head, etc.<\/p>\n<h4>4. kill():<\/h4>\n<p>This system call sends a termination signal to a process and urges the process to exit. However, it doesn\u2019t really kill a process but can have various meanings.<\/p>\n<h4>5. exit():<\/h4>\n<p>This system call terminates a process. program execution. It defines that the thread execution is complete and the OS can reclaim the resources used by the process.<\/p>\n<h3>Summary<\/h3>\n<p>System calls provide an interface between a process and an OS. Some important system calls used in OS are wait(), fork(), exec(), kill(), exit().<\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Categories<\/b><\/td>\n<td><b>Windows<\/b><\/td>\n<td><b>Unix<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Process control<\/span><\/td>\n<td><span style=\"font-weight: 400;\">CreateProcess(), ExitProcess(), WaitForSingleObject()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">fork(), exit(), wait()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Device manipulation<\/span><\/td>\n<td><span style=\"font-weight: 400;\">SetConsoleMode(), ReadConsole(), WriteConsole()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">ioctl(), read(), write()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">File manipulation<\/span><\/td>\n<td><span style=\"font-weight: 400;\">CreateFile(), ReadFile(), WriteFile(), CloseHandle()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">open(), read(), write(), close()\u00a0<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Information maintenance<\/span><\/td>\n<td><span style=\"font-weight: 400;\">GetCurrentProcessID(), SetTimer(), Sleep()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">getpid(), alarm(), sleep()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Communication<\/span><\/td>\n<td><span style=\"font-weight: 400;\">CreatePipe(), CreateFileMapping(), MapViewOfFile()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">pipe(), shm_open(), mmap()<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Protection<\/span><\/td>\n<td><span style=\"font-weight: 400;\">SetFileSecurity(), InitializeSecurityDescriptor(), SetSecurityDescriptor Group()<\/span><\/td>\n<td><span style=\"font-weight: 400;\">chmod(), umask(), chown()<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>We use system calls to provide an interface between a process and OS. A system call helps a program request services from the kernel. It is a programmatic method and the only entry point&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":100355,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24565],"tags":[24972,24970,24971],"class_list":["post-100323","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-operating-system-tutorials","tag-services-of-system-calls","tag-system-call-in-os","tag-types-of-system-calls-in-os"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>System Call in OS - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn about system call in OS. See the working of system calls, their services and types of system calls &amp; important system calls in OS.\" \/>\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\/system-call-in-os\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"System Call in OS - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn about system call in OS. See the working of system calls, their services and types of system calls &amp; important system calls in OS.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/system-call-in-os\/\" \/>\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-24T03:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/OS-System-Call.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=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"System Call in OS - DataFlair","description":"Learn about system call in OS. See the working of system calls, their services and types of system calls & important system calls in OS.","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\/system-call-in-os\/","og_locale":"en_US","og_type":"article","og_title":"System Call in OS - DataFlair","og_description":"Learn about system call in OS. See the working of system calls, their services and types of system calls & important system calls in OS.","og_url":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2021-08-24T03:30:00+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/OS-System-Call.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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9"},"headline":"System Call in OS","datePublished":"2021-08-24T03:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/"},"wordCount":746,"commentCount":2,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/OS-System-Call.jpg","keywords":["Services of system calls","System Call in OS","Types of System Calls in OS"],"articleSection":["Operating System Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/system-call-in-os\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/","url":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/","name":"System Call in OS - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/OS-System-Call.jpg","datePublished":"2021-08-24T03:30:00+00:00","description":"Learn about system call in OS. See the working of system calls, their services and types of system calls & important system calls in OS.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/system-call-in-os\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/OS-System-Call.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/08\/OS-System-Call.jpg","width":1200,"height":628,"caption":"OS System Call"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/system-call-in-os\/#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":"System Call in OS"}]},{"@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\/100323","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=100323"}],"version-history":[{"count":2,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/100323\/revisions"}],"predecessor-version":[{"id":100358,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/100323\/revisions\/100358"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/100355"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=100323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=100323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=100323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}