{"id":7968,"date":"2024-10-10T01:02:00","date_gmt":"2024-10-10T05:02:00","guid":{"rendered":"https:\/\/www.both.org\/?p=7968"},"modified":"2024-10-10T06:13:40","modified_gmt":"2024-10-10T10:13:40","slug":"what-is-an-operating-system","status":"publish","type":"post","link":"https:\/\/www.both.org\/?p=7968","title":{"rendered":"What is an operating system?"},"content":{"rendered":"<div class=\"pld-like-dislike-wrap pld-template-1\">\r\n    <div class=\"pld-like-wrap  pld-common-wrap\">\r\n    <a href=\"javascript:void(0)\" class=\"pld-like-trigger pld-like-dislike-trigger  \" title=\"\" data-post-id=\"7968\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-already-liked=\"0\">\r\n                        <i class=\"fas fa-thumbs-up\"><\/i>\r\n                <\/a>\r\n    <span class=\"pld-like-count-wrap pld-count-wrap\">1    <\/span>\r\n<\/div><\/div>\n<p>The operating system manages the operation of the computer and of the application software which runs on the computer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The definition<\/h2>\n\n\n\n<p>A simple definition of an operating system is that it is a program, much like any other program. It is different only in that its primary function is to manage the movement of data in the computer. This definition refers specifically to the kernel of the operating system.<\/p>\n\n\n\n<p>The operating system kernel manages access to the hardware devices of the computer by utility and application programs. The operating system also manages system services such as memory allocation \u2013 the assignment of specific virtual memory locations to various programs when they request memory \u2013 the movement of data from various storage devices into memory where it can be accessed by the CPU, communications with other computers and devices via the network, display of data in text or graphic format on the display, printing, and much more.<\/p>\n\n\n\n<p>The Linux kernel provides an API \u2013 application programming interface \u2013 for other programs to use in order to access the kernel functions. For example, a program that needs to have more memory allocated to its data structures uses a kernel function call to request that memory. The kernel then allocates the memory and notifies the program that the additional memory is available.<\/p>\n\n\n\n<p>The Linux kernel also manages access to the CPUs as computing resources. It uses a complex algorithm to determine which processes have are allocated some CPU time, when, and for how long. If necessary, the kernel can interrupt a running program in order to allow another program to have some CPU time.<\/p>\n\n\n\n<p>An operating system kernel like Linux can do little on its own. It requires other programs \u2013 utilities \u2013 which can be used to perform basic functions such as create a directory on the hard drive and then other program utilities to access that directory, create files in that directory, and then manage those files. These utility programs perform functions like creating files, deleting files, copying files from one place to another, setting display resolution, and complex processing of textual data. We will cover the use of many of these utilities as we proceed through this book.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Typical operating system functions<\/h2>\n\n\n\n<p>Any operating system has a set of core functions which are the primary reason for its existence. These are the functions that enable the operating system to manage itself, the hardware on which it runs, and the application programs and utilities that depend upon it to allocate system resources to them:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Memory management<\/li>\n\n\n\n<li>Managing multitasking<\/li>\n\n\n\n<li>Managing multiple users<\/li>\n\n\n\n<li>Process management<\/li>\n\n\n\n<li>Interprocess communication<\/li>\n\n\n\n<li>Device management<\/li>\n\n\n\n<li>Error handling and logging<\/li>\n<\/ul>\n\n\n\n<p>Let\u2019s look briefly at these functions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Memory management<\/h3>\n\n\n\n<p>Linux and other modern operating systems use advanced memory management strategies to virtualize real memory \u2013 random access memory<sup data-fn=\"c1d170e9-fe70-462a-8afc-b82c71e3f8c0\" class=\"fn\"><a href=\"#c1d170e9-fe70-462a-8afc-b82c71e3f8c0\" id=\"c1d170e9-fe70-462a-8afc-b82c71e3f8c0-link\">1<\/a><\/sup> (RAM) and swap memory (disk) \u2013 into a single virtual memory space which can be used as if it were all physical RAM. Portions of this virtual memory<sup data-fn=\"871782af-b3d8-449e-ad7d-e354816cc2a1\" class=\"fn\"><a href=\"#871782af-b3d8-449e-ad7d-e354816cc2a1\" id=\"871782af-b3d8-449e-ad7d-e354816cc2a1-link\">2<\/a><\/sup> can be allocated by the memory management functions of the kernel to programs that request memory.<\/p>\n\n\n\n<p>The memory management components of the operating system are responsible for assigning virtual memory space to applications and utilities, and for translation between virtual memory spaces and physical memory. The kernel allocates and deallocates memory and assigns physical memory locations based upon requests, either implicit or explicit, from application programs. In cooperation with the CPU, the kernel also manages access to memory to ensure that programs only access those regions of memory which have been assigned to them. Part of memory management includes managing the swap partition or file and the movement of memory pages between RAM and the swap space on the hard drive.<\/p>\n\n\n\n<p>Virtual memory eliminates the need for the application programmer to deal directly with memory management because it provides a single virtual memory address space for each program. It also isolates each application\u2019s memory space from that of every other, thus making the program\u2019s memory space safe from being overwritten or viewed by other programs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Multitasking<\/h3>\n\n\n\n<p>Like most modern operating systems Linux can multitask. That means that it can manage two, three, or hundreds of processes at the same time. Part of process management is managing multiple processes that are all running on a Linux computer.<\/p>\n\n\n\n<p>I usually have several programs running at one time such as LibreOffice Write which is a word processor, an email program, a spreadsheet, a file manager, a web browser, and usually multiple terminal sessions in which I interact with the Linux command-line interface (CLI). Right now, as I write this sentence, I have multiple documents open in several LibreOffice Write windows. This enables me to see what I have written in other documents and to work on multiple documents at the same time.<\/p>\n\n\n\n<p>But those programs usually do little or nothing until we give them things to do by typing words into the word processor or clicking an email to display it. I also have several terminal emulators running and use them to login to various local and remote computers for which I manage and have responsibility.<\/p>\n\n\n\n<p>Linux itself always has many programs running in the background \u2013 called daemons \u2013 programs that help Linux manage the hardware and other software running on the host. These programs are usually not noticed by users unless we specifically look for them. Some of the tools you will learn about in this course can reveal these otherwise hidden programs.<\/p>\n\n\n\n<p>Even with all of its own programs running in the background and users\u2019 programs running, a modern Linux computer uses a few compute cycles and wastes most of its CPU cycles waiting for things to happen. Linux can download and install its own updates while performing any or all of the preceding tasks simultaneously \u2013 without the need for a reboot. Wait \u2013 what?! That\u2019s right. Linux does not always need to reboot before, during or after installing updates or when installing new software. After a new kernel or glibc (General C Libraries) is installed, however, you may wish to reboot the computer to activate it, but you can do that whenever you want and not be forced to reboot multiple times during an update or even stop doing your work while the updates are installed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Multiuser<\/h3>\n\n\n\n<p>The multitasking functionality of Linux extends to its ability to host multiple users \u2013 tens or hundreds of them \u2013 all running the same or different programs at the same time on one single computer.<\/p>\n\n\n\n<p>Multiuser capabilities means a number of different things. First, it can mean a single user who has logged in multiple times via a combination of the GUI desktop interface and via the command line using one or more terminal sessions. Second, multiuser means just that \u2013 many different users logged in at the same time, each doing their own thing, and each isolated and protected from the activities of the others. Some users can be logged in locally and others from anywhere in the world with an Internet connection if the host computer is properly configured.<\/p>\n\n\n\n<p>The role of the operating system is to allocate resources to each user and to ensure that any tasks, that is, processes, they have running have sufficient resources without impinging upon the resources allocated to other users.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Process management<\/h3>\n\n\n\n<p>The Linux kernel manages the execution of all tasks running on the system. The Linux operating system is multitasking from the moment it boots up. Many of those tasks are the background tasks required to manage a multitasking and \u2013 for Linux \u2013 a multiuser environment. These tools take only a small fraction of the available CPU resources available on even modest computers.<\/p>\n\n\n\n<p>Each running program is a process. It is the responsibility of the Linux kernel to perform process management.<sup data-fn=\"1ec78a8d-b89a-4220-850c-f6728508ed4c\" class=\"fn\"><a href=\"#1ec78a8d-b89a-4220-850c-f6728508ed4c\" id=\"1ec78a8d-b89a-4220-850c-f6728508ed4c-link\">3<\/a><\/sup><\/p>\n\n\n\n<p>The scheduler portion of the kernel allocates CPU time to each running process based on its priority and whether it is capable of running. A task which is blocked \u2013 perhaps it is waiting for data to be delivered from the disk, or for input from the keyboard \u2013 does not receive CPU time. The Linux kernel will also preempt a lower priority task when a task with a higher priority becomes unblocked and capable of running.<\/p>\n\n\n\n<p>In order to manage processes, the kernel creates data abstractions that represent that process. Part of the data required is that of memory maps that define the memory that is allocated to the process and whether it is data or executable code. The kernel maintains information about the execution status such as how recently the program had some CPU time, how much time, and a number called the \u201cnice\u201d number. It uses that information and the nice number to calculate the priority of the process. The kernel uses the priority of all of the process to determine which process(es) will be allocated some CPU time.<\/p>\n\n\n\n<p>Note that not all processes need CPU time simultaneously. In fact, for most desktop workstations in normal circumstances, usually only two or three processes at the most need to be on the CPU at any given time. This means that a simple quad-core processor can easily handle this type of CPU load.<\/p>\n\n\n\n<p>If there are more programs \u2013 processes \u2013 running than there are CPUs in the system, the kernel is responsible for determining which process to interrupt in order to replace it with a different one that needs some CPU time.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Interprocess communication<\/h3>\n\n\n\n<p>Interprocess communication (IPC) is vital to any multitasking operating system. Many programs must be synchronized with each other to ensure that their work is properly coordinated. Interprocess communication is the tool that enables this type of inter-program cooperation.<\/p>\n\n\n\n<p>The kernel manages a number of IPC methods. Shared memory is used when two tasks need to pass data between them. The Linux clipboard is a good example of shared memory. Data which is cut or copied to the clipboard is stored in shared memory. When the stored data is pasted into another application, that application looks for the data in the clipboard\u2019s shared memory area. Named pipes can be used to communicate data between two programs. Data can be pushed into the pipe by one program and the other program can pull the data out of the other end of the pipe. A program may collect data very quickly and push it into the pipe. Another program may take the data out of the other end of the pipe and either display it on the screen or store it to the disk, but it can handle the data at its own rate.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Device management<\/strong><\/h3>\n\n\n\n<p>The kernel manages access to the physical hardware through the use of device drivers. Although we tend to think of this in terms of various types of storage devices, it also manages other Input\/Output (I\/O) devices such as the keyboard, mouse, display, printers, and so on. This includes management of pluggable devices such as USB storage devices, and external USB and eSATA storage devices.<\/p>\n\n\n\n<p>Access to physical devices must be managed carefully or more than one application might attempt to control the same device at the same time. The Linux kernel manages devices so that only one program actually has control of or access to a device at any given moment. One example of this is a COM port<sup data-fn=\"8baf05db-6845-4e67-8ca8-6c712c8de853\" class=\"fn\"><a href=\"#8baf05db-6845-4e67-8ca8-6c712c8de853\" id=\"8baf05db-6845-4e67-8ca8-6c712c8de853-link\">4<\/a><\/sup>. Only one program can communicate through a COM port at any given time. If you are using the COM port to get your e-mail from the Internet, for example, and try to start another program which attempts to use the same COM port, the Linux kernel detects that the COM port is already in use. The kernel then uses the hardware error handler to display a message on the screen that the COM port is in use.<\/p>\n\n\n\n<p>For managing disk I\/O devices, including USB, parallel and serial port I\/O, and file system I\/O, the kernel does not actually handle physical access to the disk, but rather manages the requests for disk I\/O submitted by the various running programs. It passes these requests on to the file system, whether it be EXT[2,3,4], VFAT, HPFS, CDFS (CD-ROM file system), or NFS (Network File System), or some other filesystem types, and manages the transfer of data between the file system and the requesting programs.<\/p>\n\n\n\n<p>All types of hardware \u2013 whether they are storage devices or something else attached to a Linux host \u2013 are handled as if they were files. In Linux, Everything is a File.<sup data-fn=\"1da29cd4-9564-447b-9946-2a18f5fa9827\" class=\"fn\"><a href=\"#1da29cd4-9564-447b-9946-2a18f5fa9827\" id=\"1da29cd4-9564-447b-9946-2a18f5fa9827-link\">5<\/a><\/sup> This results in some amazing capabilities and interesting possibilities. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Error Handling<\/h3>\n\n\n\n<p>Errors happen. As a result the kernel needs to identify these errors when they occur. The kernel may take some action such as retrying the failing operation, displaying an error message to the user, and logging the error message to a log file.<\/p>\n\n\n\n<p>In many cases the kernel can recover from errors without human intervention. In others, human intervention may be required. For example if the user attempts to unmount<sup data-fn=\"0c39d57b-8942-46f9-9d32-6abcbdfbb9b8\" class=\"fn\"><a href=\"#0c39d57b-8942-46f9-9d32-6abcbdfbb9b8\" id=\"0c39d57b-8942-46f9-9d32-6abcbdfbb9b8-link\">6<\/a><\/sup> a USB storage device that is in use, the kernel will detect this and post a message to the umount program which usually sends the error message to the user interface. The user must then take whatever action necessary to ensure that the storage device is no longer in use and then attempt the unmount the device.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Utilities<\/h2>\n\n\n\n<p>In addition to its kernel functions, most operating systems provide a number of basic utility programs which enable users to manage the computer on which the operating system resides. These are the commands such as cp, ls, mv, and so on, as well as the various shells, such as bash, ksh, csh and so on, which make using and managing the computer so much easier.<\/p>\n\n\n\n<p>These utilities are not technically part of the operating system; they are merely provided as useful tools that can be used by the SysAdmin to perform administrative tasks. In Linux, often these are the GNU core utilities. However, common usage groups the kernel together with the utilities into a single conceptual entity that we call the operating system.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<ol class=\"wp-block-footnotes\"><li id=\"c1d170e9-fe70-462a-8afc-b82c71e3f8c0\">Wikipedia, random access memory, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Random-access_memory\">https:\/\/en.wikipedia.org\/wiki\/Random-access_memory<\/a> <a href=\"#c1d170e9-fe70-462a-8afc-b82c71e3f8c0-link\" aria-label=\"Jump to footnote reference 1\">\u21a9\ufe0e<\/a><\/li><li id=\"871782af-b3d8-449e-ad7d-e354816cc2a1\">Wikipedia, Virtual Memory, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Virtual_memory\">https:\/\/en.wikipedia.org\/wiki\/Virtual_memory<\/a> <a href=\"#871782af-b3d8-449e-ad7d-e354816cc2a1-link\" aria-label=\"Jump to footnote reference 2\">\u21a9\ufe0e<\/a><\/li><li id=\"1ec78a8d-b89a-4220-850c-f6728508ed4c\">Wikipedia, Process Management, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Process_management_(computing)\">https:\/\/en.wikipedia.org\/wiki\/Process_management_(computing)<\/a> <a href=\"#1ec78a8d-b89a-4220-850c-f6728508ed4c-link\" aria-label=\"Jump to footnote reference 3\">\u21a9\ufe0e<\/a><\/li><li id=\"8baf05db-6845-4e67-8ca8-6c712c8de853\">A COM (communications) port is used with serial communications such as a serial modem to connect to the Internet over telephone lines when a cable connection is not available. <a href=\"#8baf05db-6845-4e67-8ca8-6c712c8de853-link\" aria-label=\"Jump to footnote reference 4\">\u21a9\ufe0e<\/a><\/li><li id=\"1da29cd4-9564-447b-9946-2a18f5fa9827\">Both.org,The Linux Philosophy for SysAdmins, Tenet 03 \u2014 Everything is a File, <a href=\"https:\/\/www.both.org\/?p=6843\">https:\/\/www.both.org\/?p=6843<\/a> <a href=\"#1da29cd4-9564-447b-9946-2a18f5fa9827-link\" aria-label=\"Jump to footnote reference 5\">\u21a9\ufe0e<\/a><\/li><li id=\"0c39d57b-8942-46f9-9d32-6abcbdfbb9b8\">The Linux command to unmount a device is actually umount. <a href=\"#0c39d57b-8942-46f9-9d32-6abcbdfbb9b8-link\" aria-label=\"Jump to footnote reference 6\">\u21a9\ufe0e<\/a><\/li><\/ol>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1 The operating system manages the operation of the computer and of the application software which runs on<\/p>\n","protected":false},"author":2,"featured_media":2973,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":"[{\"content\":\"Wikipedia, random access memory, <a href=\\\"https:\/\/en.wikipedia.org\/wiki\/Random-access_memory\\\">https:\/\/en.wikipedia.org\/wiki\/Random-access_memory<\/a>\",\"id\":\"c1d170e9-fe70-462a-8afc-b82c71e3f8c0\"},{\"content\":\"Wikipedia, Virtual Memory, <a href=\\\"https:\/\/en.wikipedia.org\/wiki\/Virtual_memory\\\">https:\/\/en.wikipedia.org\/wiki\/Virtual_memory<\/a>\",\"id\":\"871782af-b3d8-449e-ad7d-e354816cc2a1\"},{\"content\":\"Wikipedia, Process Management, <a href=\\\"https:\/\/en.wikipedia.org\/wiki\/Process_management_(computing)\\\">https:\/\/en.wikipedia.org\/wiki\/Process_management_(computing)<\/a>\",\"id\":\"1ec78a8d-b89a-4220-850c-f6728508ed4c\"},{\"content\":\"A COM (communications) port is used with serial communications such as a serial modem to connect to the Internet over telephone lines when a cable connection is not available.\",\"id\":\"8baf05db-6845-4e67-8ca8-6c712c8de853\"},{\"content\":\"Both.org,The Linux Philosophy for SysAdmins, Tenet 03 \u2014 Everything is a File, <a href=\\\"https:\/\/www.both.org\/?p=6843\\\">https:\/\/www.both.org\/?p=6843<\/a>\",\"id\":\"1da29cd4-9564-447b-9946-2a18f5fa9827\"},{\"content\":\"The Linux command to unmount a device is actually umount.\",\"id\":\"0c39d57b-8942-46f9-9d32-6abcbdfbb9b8\"}]"},"categories":[570,5,503,598],"tags":[599],"class_list":["post-7968","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kernel","category-linux","category-linux-101","category-operating-system","tag-operatng-system"],"modified_by":"David Both","_links":{"self":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7968"}],"version-history":[{"count":4,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7968\/revisions"}],"predecessor-version":[{"id":7973,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/posts\/7968\/revisions\/7973"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=\/wp\/v2\/media\/2973"}],"wp:attachment":[{"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.both.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}