{"id":23532,"date":"2023-04-20T09:41:08","date_gmt":"2023-04-20T09:41:08","guid":{"rendered":"https:\/\/www.booksofall.com\/?post_type=product&#038;p=23532"},"modified":"2023-04-20T09:41:09","modified_gmt":"2023-04-20T09:41:09","slug":"unix-lecture-notes-chapter-07","status":"publish","type":"product","link":"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/","title":{"rendered":"UNIX Lecture Notes &#8211; Chapter 07"},"content":{"rendered":"<p>7.1 Introduction<\/p>\n<p>In a typical operating systems course, a process is defined to be a program in execution, or something similar to that. This is a true and accurate abstraction. A program such as the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bash_(Unix_shell)\">bash shell<\/a> can have many, many instances running on a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Multi-user_software\">multi-user machine<\/a> and each individual instance is a separate and distinct process, although each and every one of these is executing the exact same executable \u001cle. What this definition does not tell you is what a process is in concrete terms. It is like saying that a baseball game is an instance of the implementation of a set of rules created by Alexander Cartwright in 1845 by which two teams compete against each other on a playing \u001cfield. Neither definition gives you a mental picture of the thing being defined. In this chapter, we focus on the concrete representation of a process in UNIX: how it is represented within the kernel, what kinds of resources it requires, how those resources are materialized and managed, what attributes it has, and what system calls are related to its control and management. As a \u001cfirst step we will look at processes from the command level. Afterward, we will look at how UNIX systems arrange their address spaces and manage them in virtual and physical memory. Then we will look at how processes are created and how they communicate and synchronize with each other.<\/p>\n<p>7.2 Examining Processes on the Command Line<\/p>\n<p>The <a href=\"https:\/\/en.wikipedia.org\/wiki\/BSD_licenses\">ps command<\/a> is used for viewing one or more processes currently known to the operating system. I say &#8220;currently known&#8221; as opposed to &#8220;active&#8221; because the list may include processes that are technically not active, so called zombie processes. The set of options available for the ps command is very system dependent. There were different versions of it in BSD systems and in Version 7, and then there are options added by <a href=\"https:\/\/en.wikipedia.org\/wiki\/GNU\">GNU<\/a>. <a href=\"https:\/\/www.redhat.com\/en\">RedHat<\/a> Linux systems support all of the historical options, and so there are many different ways to use this command in Linux. In Linux, users also have the option of running the top command. The top command is very much like ps, except that it displays the dynamic, real-time view of the state of the system. It is like the <a href=\"https:\/\/www.howtogeek.com\/405806\/windows-task-manager-the-complete-guide\/\">Windows task manager<\/a>, and also like a terminal-based version of the Gnome <a href=\"https:\/\/github.com\/GNOME\/gnome-system-monitor\">System Monitor<\/a>. Here we will describe the standard syntax rather than the BSD style or GNU syntax. The ps command without options displays the list of processes of the login id that executes it, in a short form:<\/p>\n<p id=\"fFXTbij\"><img loading=\"lazy\" decoding=\"async\" width=\"257\" height=\"79\" class=\"alignnone size-full wp-image-23536 \" src=\"https:\/\/www.booksofall.com\/wp-content\/uploads\/2023\/04\/img_644106bd860f0.png\" alt=\"\" \/><\/p>\n<p>You will notice that it always contains a line for the command itself because it itself has to run to do its job, obviously. The -f option causes it to display a full listing:<\/p>\n<p id=\"bhmcjzC\"><img loading=\"lazy\" decoding=\"async\" width=\"477\" height=\"100\" class=\"alignnone size-full wp-image-23537 \" src=\"https:\/\/www.booksofall.com\/wp-content\/uploads\/2023\/04\/img_644106c43f024.png\" alt=\"\" \/><\/p>\n<p>The UID column is the user login name. The PID column is the process id of the process. The PPID column is the parent process&#8217;s process id. The C field is rarely of interest; it gives processor utilization information. The STIME field is the starting time in hours, minutes, and seconds. The TIME column is the cumulative execution time, which for short commands will be zero, since the smallest unit of measurement in this column is seconds. The CMD column is the command line being executed by this process; in this case there are two: bash and &#8220;ps -f&#8221;. All command line arguments are displayed; if any are suppressed, the command will appear in square brackets:<\/p>\n<p id=\"tyhbdZK\"><img loading=\"lazy\" decoding=\"async\" width=\"491\" height=\"27\" class=\"alignnone size-full wp-image-23538 \" src=\"https:\/\/www.booksofall.com\/wp-content\/uploads\/2023\/04\/img_644106cc38d92.png\" alt=\"\" \/><\/p>\n<p>The TTY column is the controlling terminal attached to this process. Some processes have no terminal, in which case a &#8220;?&#8221; will appear.<\/p>\n<p>The -e option displays all processes, which will be quite long. If I want to know which process is the parent of my bash process, I can use ps -ef and \u001cfilter using grep:<\/p>\n<p id=\"iGQAXrz\"><img loading=\"lazy\" decoding=\"async\" width=\"577\" height=\"93\" class=\"alignnone size-full wp-image-23539 \" src=\"https:\/\/www.booksofall.com\/wp-content\/uploads\/2023\/04\/img_644106d90cd59.png\" alt=\"\" \/><\/p>\n<p>From this output you see that I am connected via ssh on pseudo-terminal pts\/8 and that the ssh daemon sshd is the parent of my bash process.<\/p>\n<p>You can learn a lot about a system just by running ps. For example, on our Linux system, the fi\u001crst few processes in the system are:<\/p>\n<p>$ ps -ef | head -4 UID PID PPID C STIME TTY TIME CMD root 1 0 0 Jan29 ? 00:00:01 init [5] root 2 1 0 Jan29 ? 00:00:02 [migration\/0] root 3 1 0 Jan29 ? 00:00:00 [ksoftirqd\/0<\/p>\n<p id=\"lWqEJkJ\"><img loading=\"lazy\" decoding=\"async\" width=\"545\" height=\"116\" class=\"alignnone size-full wp-image-23540 \" src=\"https:\/\/www.booksofall.com\/wp-content\/uploads\/2023\/04\/img_644106e259af8.png\" alt=\"\" \/><\/p>\n<p>whereas on our Solaris 9 server, the list is:<\/p>\n<p id=\"YlPsSDn\"><img loading=\"lazy\" decoding=\"async\" width=\"467\" height=\"118\" class=\"alignnone size-full wp-image-23541 \" src=\"https:\/\/www.booksofall.com\/wp-content\/uploads\/2023\/04\/img_644106ead78db.png\" alt=\"\" \/><\/p>\n<p>Notice that in Solaris, the (CPU) process scheduler itself is the very first process in the system. It is absent in Linux. In all UNIX systems, the process with PID 1 is always init. In Solaris, the pageout process is responsible for writing pages to disk, and fsflush \u001dflushes system bu\u001bffers to disk.<\/p>\n<p>The -u and -U options are useful for viewing all of your processes or those of others in a supplied user list. The list of users must be comma-separated, with no intervening spaces. For example:<\/p>\n<p id=\"WOnYkVP\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"132\" class=\"alignnone size-full wp-image-23542 \" src=\"https:\/\/www.booksofall.com\/wp-content\/uploads\/2023\/04\/img_644106f707d4e.png\" alt=\"\" \/><\/p>\n<p>While there are dozens of other options, I will only mention one more: the -o option. You can customize the output of the ps command to include any of the dozens of attributes available to be displayed using -o. The man page gives the general format for this. Some examples from the man page:<\/p>\n<p id=\"LUowCog\"><img loading=\"lazy\" decoding=\"async\" width=\"547\" height=\"66\" class=\"alignnone size-full wp-image-23543 \" src=\"https:\/\/www.booksofall.com\/wp-content\/uploads\/2023\/04\/img_644106fd9a0a4.png\" alt=\"\" \/><\/p>\n<p>Note that there are no spaces in the list. In general never use spaces in any of the lists because the shell will then treat them as separate words rather than a single word to be passed to the ps command itself.<\/p>\n","protected":false},"excerpt":{"rendered":"<p><iframe style=\"width: 100%; height: 750px; border: none;\" src=\"https:\/\/online.visual-paradigm.com\/share\/book\/unix-lecture-notes-chapter-07-1bs0xeht1k?p=1\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"featured_media":23544,"template":"","meta":{"_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"Operating systems is a program in execution, and in this chapter, we delve into its concrete representation in UNIX. Explore more about it in notes here!"},"product_brand":[],"product_cat":[376],"product_tag":[],"class_list":{"0":"post-23532","1":"product","2":"type-product","3":"status-publish","4":"has-post-thumbnail","6":"product_cat-unix-lecture-notes","8":"first","9":"instock","10":"shipping-taxable","11":"product-type-simple"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>UNIX Lecture Notes - Chapter 07 - BooksOfAll French<\/title>\n<meta name=\"description\" content=\"Operating systems is a program in execution, and in this chapter, we delve into its concrete representation in UNIX. Explore more about it in notes here!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"UNIX Lecture Notes - Chapter 07 - BooksOfAll French\" \/>\n<meta property=\"og:description\" content=\"Operating systems is a program in execution, and in this chapter, we delve into its concrete representation in UNIX. Explore more about it in notes here!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/\" \/>\n<meta property=\"og:site_name\" content=\"BooksOfAll French\" \/>\n<meta property=\"article:modified_time\" content=\"2023-04-20T09:41:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg\" \/><meta property=\"og:image\" content=\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"827\" \/>\n\t<meta property=\"og:image:height\" content=\"1169\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/\",\"url\":\"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/\",\"name\":\"UNIX Lecture Notes - Chapter 07 - BooksOfAll French\",\"isPartOf\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg\",\"datePublished\":\"2023-04-20T09:41:08+00:00\",\"dateModified\":\"2023-04-20T09:41:09+00:00\",\"description\":\"Operating systems is a program in execution, and in this chapter, we delve into its concrete representation in UNIX. Explore more about it in notes here!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/#breadcrumb\"},\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/#primaryimage\",\"url\":\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg\",\"contentUrl\":\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg\",\"width\":\"827\",\"height\":\"1169\",\"caption\":\"UNIX Lecture Notes - Chapter 07\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.booksofall.com\/fr\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Categories\",\"item\":\"https:\/\/www.booksofall.com\/fr\/categories\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"UNIX Lecture Notes &#8211; Chapter 07\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/#website\",\"url\":\"https:\/\/www.booksofall.com\/fr\/\",\"name\":\"BooksOfAll French\",\"description\":\"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.\",\"publisher\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.booksofall.com\/fr\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/#organization\",\"name\":\"BooksOfAll French\",\"url\":\"https:\/\/www.booksofall.com\/fr\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/www.booksofall.com\/fr\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2022\/06\/booksofall-logo-2.png\",\"contentUrl\":\"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2022\/06\/booksofall-logo-2.png\",\"width\":166,\"height\":30,\"caption\":\"BooksOfAll French\"},\"image\":{\"@id\":\"https:\/\/www.booksofall.com\/fr\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"UNIX Lecture Notes - Chapter 07 - BooksOfAll French","description":"Operating systems is a program in execution, and in this chapter, we delve into its concrete representation in UNIX. Explore more about it in notes here!","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:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/","og_locale":"fr_FR","og_type":"article","og_title":"UNIX Lecture Notes - Chapter 07 - BooksOfAll French","og_description":"Operating systems is a program in execution, and in this chapter, we delve into its concrete representation in UNIX. Explore more about it in notes here!","og_url":"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/","og_site_name":"BooksOfAll French","article_modified_time":"2023-04-20T09:41:09+00:00","og_image":[{"url":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg","type":"","width":"","height":""},{"width":827,"height":1169,"url":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_image":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg","twitter_misc":{"Dur\u00e9e de lecture estim\u00e9e":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/","url":"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/","name":"UNIX Lecture Notes - Chapter 07 - BooksOfAll French","isPartOf":{"@id":"https:\/\/www.booksofall.com\/fr\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/#primaryimage"},"image":{"@id":"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/#primaryimage"},"thumbnailUrl":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg","datePublished":"2023-04-20T09:41:08+00:00","dateModified":"2023-04-20T09:41:09+00:00","description":"Operating systems is a program in execution, and in this chapter, we delve into its concrete representation in UNIX. Explore more about it in notes here!","breadcrumb":{"@id":"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/#breadcrumb"},"inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/#primaryimage","url":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg","contentUrl":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2023\/04\/UNIX-Lecture-Notes-cover-UNIX-Lecture-Notes-Chapter_07.jpg","width":"827","height":"1169","caption":"UNIX Lecture Notes - Chapter 07"},{"@type":"BreadcrumbList","@id":"https:\/\/www.booksofall.com\/fr\/unix-lecture-notes-chapter-07\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.booksofall.com\/fr\/"},{"@type":"ListItem","position":2,"name":"Categories","item":"https:\/\/www.booksofall.com\/fr\/categories\/"},{"@type":"ListItem","position":3,"name":"UNIX Lecture Notes &#8211; Chapter 07"}]},{"@type":"WebSite","@id":"https:\/\/www.booksofall.com\/fr\/#website","url":"https:\/\/www.booksofall.com\/fr\/","name":"BooksOfAll French","description":"Biggest IT eBooks library and learning resources - Free eBooks for programming, computing, artificial intelligence and more.","publisher":{"@id":"https:\/\/www.booksofall.com\/fr\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.booksofall.com\/fr\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":"Organization","@id":"https:\/\/www.booksofall.com\/fr\/#organization","name":"BooksOfAll French","url":"https:\/\/www.booksofall.com\/fr\/","logo":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/www.booksofall.com\/fr\/#\/schema\/logo\/image\/","url":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2022\/06\/booksofall-logo-2.png","contentUrl":"https:\/\/www.booksofall.com\/fr\/wp-content\/uploads\/sites\/6\/2022\/06\/booksofall-logo-2.png","width":166,"height":30,"caption":"BooksOfAll French"},"image":{"@id":"https:\/\/www.booksofall.com\/fr\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/product\/23532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/product"}],"about":[{"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/types\/product"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/media\/23544"}],"wp:attachment":[{"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/media?parent=23532"}],"wp:term":[{"taxonomy":"product_brand","embeddable":true,"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/product_brand?post=23532"},{"taxonomy":"product_cat","embeddable":true,"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/product_cat?post=23532"},{"taxonomy":"product_tag","embeddable":true,"href":"https:\/\/www.booksofall.com\/fr\/wp-json\/wp\/v2\/product_tag?post=23532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}