<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Demo on Medium]]></title>
        <description><![CDATA[Stories by Demo on Medium]]></description>
        <link>https://medium.com/@demozeik?source=rss-662a1b5b0baf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MBmPvWPMIdKQ4ISCa_c9Tw.jpeg</url>
            <title>Stories by Demo on Medium</title>
            <link>https://medium.com/@demozeik?source=rss-662a1b5b0baf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 05:58:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@demozeik/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Tugas Menganalisis Program File Explorer (Tugas UAS)]]></title>
            <link>https://medium.com/@demozeik/tugas-menganalisis-program-file-explorer-tugas-uas-4ebdc08d6c52?source=rss-662a1b5b0baf------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ebdc08d6c52</guid>
            <dc:creator><![CDATA[Demo]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 05:23:26 GMT</pubDate>
            <atom:updated>2018-08-05T12:12:15.977Z</atom:updated>
            <content:encoded><![CDATA[<p>Sebelum kita membahas mengenai File explorer, kita akan menyinggung terlebih dahulu suatu topik yang berkaitan dengan File explorer, yaitu manajer berkas.</p><p>Mengapa kita myangkut pautkan manajer berkas dengan program file explorer?</p><p>Tentu saja ada sangkut pautnya, karena program file explorer itu sendiri merupakan sebuah program manajemen berkas yang di gunakan sebagai antar muka dalam suatu sistem operasi untuk mempermudah interaksi antara pengguna dengan sistem komputer yang berjalan.</p><p>Manajer berkas (bahasa Inggris: file manager atau file browser) adalah sebuah perangkat lunak yang menyediakan antarmuka untuk bekerja dengan sistem berkas. Perangkat lunak ini sangat berguna untuk mempercepat interaksi dengan berkas. Pekerjaan yang umum yang berhubungan dengan berkas adalah membuat, membuka, menyunting, melihat, mencetak, memainkan, mengubah nama, memindahkan, menyalin, menghapus, mengganti atribut, mencari dan mengubah izin penggunaan. <br>Umumnya berkas ditampilkan dalam sistem hierarki. Manajer berkas yang modern memiliki beberapa fitur yang diinspirasi dari penjelajah web antara lain tombol navigasi maju dan kembali. <br>Beberapa manajer berkas menyediakan kemampuan konektivitas dengan jaringan misalnya lewat FTP, NFS, SMB atau WebDAV.</p><h4><strong>Manajemen File dengan File Explorer (system shell)</strong></h4><p>File Eksplorer (File Manager) adalah aplikasi pengelola berkas untuk sebuah sistem operasi, baik itu yang berjalan di PC maupun gadget yang memungkinkan pengguna untuk bekerja dengan berkas dalam cara yang sangat mirip seperti melakukannya pada komputer desktop. Misalnya memotong, melekatkan serta menyalin berkas dan folder. File Manager adalah sebuah pengelola berkas sederhana namun memiliki semua fitur yang anda perlukan, antar muka yang nyaman dan mudah digunakan, serta dioptimalkan.</p><p>Ada pun program file eksplorer yang kita bangun &amp; analisis dibuat dengan menggunakan PHP, alasan kita menggunakan PHP untuk membuat dan menganalisis program file eksplorer yang di tugaskan dosen adalah bla bla bla …. itu rahasia lah ha ha ha. Yang jelas lagi malas &amp; kebetulan pengennya ya buat yang bisa kita buat, begitu toh. Sok jadi jangan banyak tanya yah</p><p>Ok tanpa mengulur waktu lebih lama berikut kita tampilkan hasil analisis kita terhadap program aplikasi file explorer (sistem shell), yang telah kita analisis entah sejak kapan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47FxLPY4pfIWtF5O9e9e5Q.png" /><figcaption>Gambar 1. Tampilan File Explorer di PC</figcaption></figure><p>ini adalah tampilan antar muka file explorer nya, di sana terdapat beberapa macam fungsi yang tentunya kalian sudah tidak asing. beberapa fungsi itu antara lain :</p><p>klik directory, untuk masuk ke directory</p><p>klik satu kali pada file yang di “linked” untuk mendowload file atau menyimpan file pada penyimpanan lain di luar local host</p><p>untuk membuka atau menampilkan file kalian dapat mengklik tombol view, atau jika ingin mengedit file tersebut jika file explorer memiliki capability untuk mengeditnya, kalian dapat menekan tombol edit. Tidak semua file dapat di edit, hanya file dengan ekstensi tertentu saja yang dapat di edit melalui file explorer ini.</p><p>Berikut tampilan jika kita akan mengedit file dari file explorer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_g9AyVh7Ex9dTcvjKuFxw.png" /><figcaption>Gambar 2. Tampilan edit lewat file explorer</figcaption></figure><p>ternyata file nya hanya dapat di buka dengan ektensi .txt, karena itulah mengapa tidak semua file dapat di edit dengan menggunakan aplikasi file explorer ini.</p><p>untuk mengganti nama file, dapat mengklik tombol “rename”</p><p>untuk menghapus file atau folder dapat mengklik tombol “delete”</p><p>untuk memilih atau memblok semua file yang akan di pilih, dapat dilakukan dengan menekan tombol “all”, maka semua file akan terpilih</p><p>sedangkan jika anda hanya ingin memilih beberapa file tertentu, anda dapat memilih tombol “all” kemudian klok tombol “invers” untuk memilih file atau folder tertentu yang terpilih</p><p>Jika ingin meng-copy file, anda dapat melakukannya dengan klik terlebih dahulu file atau folder target kolom sebelah kanan kemudian klik copy. kemudian pilih folder tujuan di kolom sebelah kiri. Berikut tampilannya:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ERslM9nYqB8t3VmU0ly4Xg.png" /><figcaption>Gambar 3. Tampilan saat akan melakukan copy file</figcaption></figure><p>Untuk memindahkan file atau folder ke directory lain, anda dapat melakukannya dengan klik terlebih dahulu file atau folder target di kolom sebelah kanan kemudian klik tombol “move” kemudian pilih folder kolom sebelah kiri untuk tujuan file tersebut akan di simpan, kemudian klik. Tombol “move” ini sama fungsinya dengan tombol “Cut” jika di windows yaitu melakukan “cut” terhadap file atau folder terpilih dan kemudian memindahkannya ke folder tujuan. Berikut tampilannya:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ByqfkTxqaz76XUoOkUbpw.png" /><figcaption>Gambaran 4. tampilan saat melakukan fungsi Move (sma dengan fungsi Cut) File</figcaption></figure><p>Adapun tombol compress fungsinya adalah untuk mengkompress file menjadi lebih kecil ke dalam format RAR atau lainnya yang memiliki ekstensi semacam itu. Caranya adalah dengan klik terlebih dahulu target file atau folder (dapat beberapa file atau folder, tidak hanya satu) kemudian klik “compress”. berikut tampilannya :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBeDc5hijWa6JjU1ihbxqw.png" /><figcaption>Gambar 5. Tampilan saat akan meng-compress File</figcaption></figure><p>Adapun tombol Permissions, fungsinya adalah untuk mengatur hak akses atau permission terhadap file atau folder yang di pilih. Caranya adalah pilih &amp; klik terlebih dahulu folder atau file target yg di pilih, kemudian klik tombol “permissions”. Berikut adalah tampilannya :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DF7xRLgG6GELdA3QVqFqLg.png" /><figcaption>Gambar 6. Tampilan saat mengakses “Change Permission” dan akan merubah Permission</figcaption></figure><p>dengan tombol permissions kita dapat mengatur hak akses file atau folder tertentu sesuai keinginan kita.</p><p>Baiklah para pembaca sekalian, sekian analisis dari kami mengenai program aplikasi File explorer yang telah kami buat. Mohon maaf bila ada kekurangan dalam penyampaian topik tentang analisis ini. Cukup Sekian</p><p><strong>Anggota Kelompok :</strong></p><p><strong>10517705 Dadi Agustina P</strong></p><p><strong>10512015 Insan Rachman (Kelas S0–2 tpi ikut ke kelompok katanya gak dapat kelompok)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ebdc08d6c52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[File terdahulu yang udah di post tapi hilang dari muka bumi karena di suspend postingannya]]></title>
            <link>https://medium.com/@demozeik/file-terdahulu-yang-udah-di-post-tapi-hilang-dari-muka-bumi-karena-di-suspend-postingannya-52a24ccd8f2a?source=rss-662a1b5b0baf------2</link>
            <guid isPermaLink="false">https://medium.com/p/52a24ccd8f2a</guid>
            <category><![CDATA[computers]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[análisis]]></category>
            <category><![CDATA[system]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Demo]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 03:55:07 GMT</pubDate>
            <atom:updated>2018-07-26T03:55:07.222Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Anjay malang bener nasibku udah ketiga kalinya post aku hilang di suspend, sekarang yang hilang postingan untuk tugas mata kuliah sistem operasi Quis 4 tentang <em>Raid Technology</em>, entah gara-gara sering di refresh pas lagi posting atau karena hal lain. Tapi pernah waktu ngerjain posting yang pertama post aku di suspend juga, terus ganti judul. eh tau nya bisa gak di suspend itu topik tugas SO aku yang pertama. Masa gara-gara judul topik yang kita post di suspend sih, kan gak banget gitu loh. Tapi anehnya setelah ganti judul, itu postingan ku yang pertama bisa <em>publish </em>tanpa di suspend. Melalui kata pembuka yang singkat ini, setidaknya pembaca mengetahui apa yang pernah ku alami selama mengelola akun ini. ok sekarang kita sudahi saja curhatannya, ayo kita mulai membaca postingan ku yang di suspend. Aku post lagi hari ini semoga ada manfaatnya buat para pembaca sekalian.</p><p>Kali ini kita akan membahas mengenai RAID Storage (Data Storage Virtualization).</p><p>RAID is a method of combining several hard disk drives into one logical unit (two or more disks grouped together to appear as a single device to the host system). RAID technology was developed to address the fault-tolerance and performance limitations of conventional disk storage. It can offer fault tolerance and higher throughput levels than a single hard drive or group of independent hard drives. While arrays were once considered complex and relatively specialized storage solutions, today they are easy to use and essential for a broad spectrum of client/server applications.</p><p>RAID is an acronym for <strong>R</strong>edundant <strong>A</strong>rray of <strong>I</strong>ndependent <strong>D</strong>isks, and it’s a core feature of server hardware that ensures data integrity. It’s also just a fancy word for two or more hard disks connected together to add some additional functionality. Why would you want to do this? Read on.</p><h4>History</h4><p>RAID technology was first defined by a group of computer scientists at the University of California at Berkeley in 1987. The scientists studied the possibility of using two or more disks to appear as a single device to the host system.<br> Although the array’s performance was better than that of large, single-disk storage systems, reliability was unacceptably low. To address this, the scientists proposed redundant architectures to provide ways of achieving storage fault tolerance. In addition to defining RAID levels 1 through 5, the scientists also studied data striping — a non-redundant array configuration that distributes files across multiple disks in an array. Often known as RAID 0, this configuration actually provides no data protection. However, it does offer maximum throughput for some data-intensive applications such as desktop digital video production.</p><h4>The driving factors behind RAID</h4><p>A number of factors are responsible for the growing adoption of arrays for critical network storage.<br> More and more organizations have created enterprise-wide networks to improve productivity and streamline information flow. While the distributed data stored on network servers provides substantial cost benefits, these savings can be quickly offset if information is frequently lost or becomes inaccessible. As today’s applications create larger files, network storage needs have increased proportionately. In addition, accelerating CPU speeds have outstripped data transfer rates to storage media, creating bottlenecks in today’s systems.<br> RAID storage solutions overcome these challenges by providing a combination of outstanding data availability, extraordinary and highly scalable performance, high capacity, and recovery with no loss of data or interruption of user access.<br> By integrating multiple drives into a single array — which is viewed by the network operating system as a single disk drive — organizations can create cost-effective, minicomputersized solutions of up to a terabyte or more of storage.</p><h4>RAID Configurations</h4><p>First off, it’s very difficult to describe RAID technologies as a whole, because the different configurations available to you create very different functionalities — but they all focus on either speed or reliability. Let’s break them down:</p><h4>RAID 0: Striped</h4><p>This configuration is all about speed. In short, data is spread across a number of disks (<em>striped</em> across the disks, in fact) — rather than being written to just one. This overcomes speed limitations of a single drive, so performance is theoretically multiplied by the number of disks you are using.</p><p>It’s a similar concept to having 4 cores in your CPU — instead of sequentially writing instructions to one CPU, you send different parts of it to 4 different CPUs, and get the answers back 4 times as quickly. You also get to use the combined space of all of the drives, so 2 x 1TB in a striped configuration will show as a single 2TB drive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*5aUHHMT2wk0gDh8h.png" /></figure><p>On the downside, you also have as many points of failure as drives you are using — if just one of those drives fails, all your data will be lost. In reality then, this configuration is rarely used. If the data isn’t so valuable though, you might want to set up a RAID0 on a home server or even a desktop machine.</p><h4>RAID 1: Mirrored</h4><p>This configuration is all about data integrity and is far easier to explain. In a RAID 1 setup, data is mirrored to the other drives — a full backup of everything is kept at all times, because the bits of data are simultaneously written to different drives, at the same time. Because of this, you only get the total drive space of a single drive, so 2 x 1TB drives set up to mirror each other will only give you 1TB total space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*vI8_myym-PsvQTWE.png" /></figure><p>This is perhaps the most common real world usage when two disks are available. When one dies, the data is still 100% there and ready for use, but the process of “re-building” the data array on the replacement drive can take a very long time.</p><h4>RAID 0+1: Striped &amp; Mirrored</h4><p>This combines the best of both worlds by nesting RAID setups, but requires at least 4 disks. 2 sets of 2 striped disks are then set up, each set replicated to the other. RAID 1+0 also exists, but doesn’t vary enough to warrant a separate explanation — it’s a case of striping your mirrors rather than mirroring your stripes!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*41Gjnb6kMpzZoH9_.png" /></figure><h4>RAID 2 &amp; Above: Parity Bits</h4><p>With 3 disks, you can actually achieve a good performance and integrity compromise by using what is called a parity disk. To explain this, think on a scale of bits instead of whole drives.</p><p>A parity bit is simply an XOR combination on the other bits. XOR is a logic operation that evaluates to true if only ONE of the two input bits is true. See the following table, where P is the parity bit.</p><p>A B<strong> P</strong><br> 0 0 <strong>0</strong><br> 0 1 <strong>1</strong><br> 1 0 <strong>1</strong><br> 1 1 <strong>0</strong></p><p>Now it turns out that this is very useful for error checking and repairing the data. If you were to erase the entire <strong>B</strong> column, you could rebuild it simply because you still have both the parity bit and <strong>A</strong>, and given those then there is only one possible answer for bit <strong>B</strong>.</p><p>Now, it should be easy to see that even if we had 2 x 1 terabyte drives worth of bits, we could still create a parity for every single bit and place it on a 3rd drive that’s also a terabyte in size. And that’s RAID3. With a 3 disk array, 2 are used to stripe the data, spreading it out for performance. The 3rd drive creates a parity set, and if any one of those drives dies, we can use the other 2 to recover it in full.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/0*iblgACZrFuVs7oEX.png" /></figure><p>I won’t go into details about RAID 3, 4, 5 and 6 because they’re basically all variants on where and how parity bits are stored or derived, and precisely how much recovery can be done. If you’d like to read up on those, I’d suggest the extensive <a href="http://en.wikipedia.org/wiki/RAID">Wikipedia page </a>on the topic.</p><h4>Can I Use RAID On My Home PC? Should I?</h4><p>Both OSX and Windows have the ability to create software RAID configurations, but bear in mind that this is going to increase the load on your operating system due to the additional computation required.</p><p>A lot of motherboards also include a form of semi-hardware RAID — I say semi-hardware, because they generally still need a driver in your OS to be able to access the data, but this is still one step up from a purely software RAID, and you can even install the OS onto them for a small performance boost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/0*DcPFpJH1EfyDxj-E.png" /></figure><p>The final method of doing RAID is with dedicated hardware — upgrade cards that you can slot into your PC and take full control of the data side of things. These are of course the most reliable and best performing, but the price range is generally out of consumer budgets.</p><p>As for whether you <em>should</em> be using a RAID, it’s certainly worth playing around with for geek points. In terms of real world computing, the performance gains you can expect are often less than the trouble involved (<a href="https://www.makeuseof.com/pages/download-hard-drive-of-the-future-101-guide-to-solid-state-drives">an SSD</a> would far outperform them anyway), or the data redundancy you gain can be easily achieved with other traditional backup methods.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52a24ccd8f2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quest 02 & 03 : Multithreading in Operating System]]></title>
            <link>https://medium.com/@demozeik/quest-02-03-multithreading-in-operating-system-bfa2d2194a83?source=rss-662a1b5b0baf------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfa2d2194a83</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[multithreading]]></category>
            <category><![CDATA[operating-systems]]></category>
            <dc:creator><![CDATA[Demo]]></dc:creator>
            <pubDate>Thu, 26 Apr 2018 03:20:15 GMT</pubDate>
            <atom:updated>2018-08-05T12:27:51.800Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>The multithreading paradigm has become more popular as efforts to further exploit instruction-level parallelism have stalled since the late 1990s.</strong></p><p>Before i explain about Multithreading, first i have to explain about Thread, if you don’t know about Thread probably you guys hard to understand what Multithreading is.</p><h3><strong>What is Thread?</strong></h3><p>A thread is a flow of execution through the process code, with its own program counter that keeps track of which instruction to execute next, system registers which hold its current working variables, and a stack which contains the execution history.</p><p>A thread shares with its peer threads few information like code segment, data segment and open files. When one thread alters a code segment memory item, all other threads see that.</p><p>A thread is also called a <strong>lightweight process</strong>. Threads provide a way to improve application performance through parallelism. Threads represent a software approach to improving performance of operating system by reducing the overhead thread is equivalent to a classical process.</p><p>Each thread belongs to exactly one process and no thread can exist outside a process. Each thread represents a separate flow of control. Threads have been successfully used in implementing network servers and web server. They also provide a suitable foundation for parallel execution of applications on shared memory multiprocessors. The following figure shows the working of a single-threaded and a multithreaded process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*_MHahkou-coeq5Py.jpg" /></figure><h4>Difference between Process and Thread</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*DUr2K1I6PA6Y2zc15MrZ6A.jpeg" /></figure><h4>Advantages of Thread</h4><ul><li>Threads minimize the context switching time.</li><li>Use of threads provides concurrency within a process.</li><li>Efficient communication.</li><li>It is more economical to create and context switch threads.</li><li>Threads allow utilization of multiprocessor architectures to a greater scale and efficiency.</li></ul><h4><strong>Types of Thread</strong></h4><p>Threads are implemented in following two ways −</p><ul><li><strong>User Level Threads</strong> − User managed threads.</li><li><strong>Kernel Level Threads</strong> − Operating System managed threads acting on kernel, an operating system core.</li></ul><blockquote>User Level Threads</blockquote><p>In this case, the thread management kernel is not aware of the existence of threads. The thread library contains code for creating and destroying threads, for passing message and data between threads, for scheduling thread execution and for saving and restoring thread contexts. The application starts with a single thread.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*ohKPTZb6w-aCXfgq.jpg" /></figure><p>Advantages</p><ul><li>Thread switching does not require Kernel mode privileges.</li><li>User level thread can run on any operating system.</li><li>Scheduling can be application specific in the user level thread.</li><li>User level threads are fast to create and manage.</li></ul><p>Disadvantages</p><ul><li>In a typical operating system, most system calls are blocking.</li><li>Multithreaded application cannot take advantage of multiprocessing.</li></ul><blockquote>Kernel Level Threads</blockquote><p>In this case, thread management is done by the Kernel. There is no thread management code in the application area. Kernel threads are supported directly by the operating system. Any application can be programmed to be multithreaded. All of the threads within an application are supported within a single process.</p><p>The Kernel maintains context information for the process as a whole and for individuals threads within the process. Scheduling by the Kernel is done on a thread basis. The Kernel performs thread creation, scheduling and management in Kernel space. Kernel threads are generally slower to create and manage than the user threads.</p><p>Advantages</p><ul><li>Kernel can simultaneously schedule multiple threads from the same process on multiple processes.</li><li>If one thread in a process is blocked, the Kernel can schedule another thread of the same process.</li><li>Kernel routines themselves can be multithreaded.</li></ul><p>Disadvantages</p><ul><li>Kernel threads are generally slower to create and manage than the user threads.</li><li>Transfer of control from one thread to another within the same process requires a mode switch to the Kernel.</li></ul><h4>What are Thread Libraries?</h4><p>Thread libraries provide programmers with API for creation and management of threads.</p><p>Thread libraries may be implemented either in user space or in kernel space. The user space involves API functions implemented solely within the user space, with no kernel support. The kernel space involves system calls, and requires a kernel with thread library support.</p><h4>Three types of Thread</h4><ol><li><strong>POSIX Pitheads</strong>, may be provided as either a user or kernel library, as an extension to the POSIX standard.</li><li><strong>Win32 threads</strong>, are provided as a kernel-level library on Windows systems.</li><li><strong>Java threads</strong>: Since Java generally runs on a Java Virtual Machine, the implementation of threads is based upon whatever OS and hardware the JVM is running on, i.e. either Pitheads or Win32 threads depending on the system.</li></ol><h3>Multithreading Models</h3><p>Multithreading is the ability of an operating system process to manage its use by more than one user at a time and to even manage multiple requests by the same user without having to have multiple copies of the programming running in the computer. Each user request for a program or system service (and here a user can also be another program) is kept track of as a thread with a separate identity. As programs work on behalf of the initial request for that thread and are interrupted by other requests, the status of work on behalf of that thread is kept track of until the work is completed.</p><p>Multithreading is a technique that allows a program or a process to execute many tasks concurrently. at the same time and parallel. It allows a process to run its tasks in parallel mode on a single processor system.</p><p>A multithreading is a specialized form of multitasking. Multitasking threads require less overhead than multitasking processes. I need to define another term related to threads process: A process consists of the memory space allocated by the operating system that can contain one or more threads. A thread cannot exist on its own; it must be a part of a process. A process remains running until all of the non-daemon threads are done executing.<br>Multithreading enables you to write very efficient programs that make maximum use of the CPU, because idle time can be kept to a minimum.<br>Advantages of multithreading over multitasking :</p><ul><li>Reduces the computation time.</li><li>Improves performance of an application.</li><li>Threads share the same address space so it saves the memory.</li><li>Context switching between threads is usually less expensive than between processes.</li><li>Cost of communication between threads is relatively low.</li></ul><p>Thread libraries provide programmers with an API for creating and managing threads like java threads.</p><ul><li>For example in a word processor, one thread may check for spelling mistakes while another thread stores or process the inputs simultaneously.</li><li>Another good example is web server, where multiple threads works on multiple requests sent by clients.</li><li>Many GUI frameworks are multi-threaded.</li><li>bulk updating data files (eg adding a value / entry to 10,000 records)</li></ul><p>Concrete Examples:</p><ul><li><strong>Microsoft Word</strong></li><li><strong>Microsoft Excel</strong></li><li><strong>Web Browser</strong></li></ul><p>Bottom-line, multi-threading is found everywhere and in every applications.</p><p>Some operating system provide a combined user level thread and Kernel level thread facility. Solaris is a good example of this combined approach. In a combined system, multiple threads within the same application can run in parallel on multiple processors and a blocking system call need not block the entire process. Multithreading models are three types</p><ul><li>Many to many relationship.</li><li>Many to one relationship.</li><li>One to one relationship.</li></ul><blockquote>Many to Many Model</blockquote><p>The many-to-many model multiplexes any number of user threads onto an equal or smaller number of kernel threads.</p><p>The following diagram shows the many-to-many threading model where 6 user level threads are multiplexing with 6 kernel level threads. In this model, developers can create as many user threads as necessary and the corresponding Kernel threads can run in parallel on a multiprocessor machine. This model provides the best accuracy on concurrency and when a thread performs a blocking system call, the kernel can schedule another thread for execution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*Xob6HYmGqMwbRkLI.png" /></figure><blockquote>Many to One Model</blockquote><p>Many-to-one model maps many user level threads to one Kernel-level thread. Thread management is done in user space by the thread library. When thread makes a blocking system call, the entire process will be blocked. Only one thread can access the Kernel at a time, so multiple threads are unable to run in parallel on multiprocessors.</p><p>If the user-level thread libraries are implemented in the operating system in such a way that the system does not support them, then the Kernel threads use the many-to-one relationship modes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*-jLLWxWJnmLqSpM7.png" /></figure><blockquote>One to One Model</blockquote><p>There is one-to-one relationship of user-level thread to the kernel-level thread. This model provides more concurrency than the many-to-one model. It also allows another thread to run when a thread makes a blocking system call. It supports multiple threads to execute in parallel on microprocessors.</p><p>Disadvantage of this model is that creating user thread requires the corresponding Kernel thread. OS/2, windows NT and windows 2000 use one to one relationship model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*08ZPGrfVRjRXtBjK.png" /></figure><h4>Difference between User-Level &amp; Kernel-Level Thread</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*fSZdwnrN8qvWNZFxmT6-gg.jpeg" /></figure><h4>Benefits of Multithreading</h4><ol><li>Responsiveness</li><li>Resource sharing, hence allowing better utilization of resources.</li><li>Economy. Creating and managing threads becomes easier.</li><li>Scalability. One thread runs on one CPU. In Multithreaded processes, threads can be distributed over a series of processors to scale.</li><li>Context Switching is smooth. Context switching refers to the procedure followed by CPU to change from one task to another.</li></ol><h4>Multithreading Issues</h4><p>Below we have mentioned a few issues related to multithreading. Well, it’s an old saying, <em>All good things, come at a price.</em></p><h4>Thread Cancellation</h4><p>Thread cancellation means terminating a thread before it has finished working. There can be two approaches for this, one is <strong>Asynchronous cancellation</strong>, which terminates the target thread immediately. The other is <strong>Deferred cancellation</strong> allows the target thread to periodically check if it should be cancelled.</p><h4>Signal Handling</h4><p>Signals are used in UNIX systems to notify a process that a particular event has occurred. Now in when a Multithreaded process receives a signal, to which thread it must be delivered? It can be delivered to all, or a single thread.</p><h4>fork() System Call</h4><p>fork() is a system call executed in the kernel through which a process creates a copy of itself. Now the problem in Multithreaded process is, if one thread forks, will the entire process be copied or not?</p><h4>Security Issues</h4><p>Yes, there can be security issues because of extensive sharing of resources between multiple threads.</p><p>There are many other issues that you might face in a multithreaded process, but there are appropriate solutions available for them. Pointing out some issues here was just to study both sides of the coin.</p><h4><strong>QUEST 02</strong></h4><h4><strong>Examples of some Multithreading Programs in Java</strong></h4><blockquote>Multithreading Program 1</blockquote><p>public class DadiAP { <br>public static void main (String [] args) { <br>Mobil m1 = new Mobil(“M-1”); <br>Mobil m2 = new Mobil(“M-2”); <br>m2.setPriority(8); // digunakan untuk mengatur prioritas m2 agar lebih tinggi daripada m1, biar gak lupa pake comment ini<br>m1.start(); <br>m2.start(); <br>} <br>} <br>class Mobil extends Thread { <br>// konstruktor <br>public Mobil (String id) { <br>super (id); <br>} <br>// Mendefinisikan sendiri run() <br>public void run() { <br>String nama = getName(); <br>for (int i=0; i&lt;5; i++) { <br>System.out.println(“Thread “ + nama + “:Posisi “ + i ); <br>} <br>} <br>}</p><p>Output Program :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*kCChA5_gfc4a9cgJhbf8jQ.jpeg" /></figure><blockquote>Multithreading Program 2</blockquote><p>class belThreading extends Thread<br>{<br> public void cobaThread212()<br> {<br> try<br> {<br> for (int i = 0; i &lt; 10; i++)<br> {<br> System.out.println(“Thread 212 “ + i);<br> Thread.sleep(1000);<br> }<br> }<br> catch(Exception e)<br> {<br> }<br> }<br> public void cobaThread213()<br> {<br> try<br> {<br> for (int i = 0; i &lt; 10; i++)<br> {<br> System.out.println(“Thread 213 “ + i);<br> Thread.sleep(1000);<br> }<br> }<br> catch(Exception e)<br> {<br> }<br> }<br>}<br>public class Main {<br> <br> public static void main(String[] args) {<br> System.out.println(“MultiThreading”);<br> <br> belThreading tid1 = new belThreading();<br> <br> tid1.cobaThread212();<br> tid1.cobaThread213();<br> <br> System.out.println(“End”);<br> }<br>}</p><p>Output Program :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*2yosx5Jk74XbwmD976mBCg.jpeg" /></figure><blockquote>Multithreading Program 3</blockquote><p>class dida extends Thread<br>{<br>public int name,i;<br>public void run()<br>{<br> for(i=1;i&lt;=20;i++)<br> {<br> System.out.println(“ Thread “ + name + “ : “ + i);<br> try<br> {<br> sleep(2000); /** untuk membuat delay 2 detik sesuai perintah tugas pak Ferry */<br> }<br> catch(Exception e)<br> {<br> System.out.println(“some problem”);<br> }<br> }<br>}<br>}<br>public class dadi<br>{<br>public static void main(String[] args)<br>{<br> dida a=new dida();<br> dida b=new dida();<br> a.name=111;<br> b.name=112;<br> a.start();<br> b.start();<br>}<br>}</p><p>Output Program :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*ht99M0SukXq_S-40OFMilA.jpeg" /></figure><h4><strong>Quest 03</strong></h4><h4>What we have done?</h4><p>we have made a resume about the concept of multithreading in the operating system &amp; we learned something new in programming. After we learned a lot, we also made a number of programs to improve our skills, scroll up and you can see what we have done to complete the assignment that Mr Ferry gave to us. Thanks to Mr Ferry as our Lecturer and anyone who helped us so we could complete our assignments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfa2d2194a83" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Operating System]]></title>
            <link>https://medium.com/@demozeik/introduction-to-operating-system-3274f0ff947d?source=rss-662a1b5b0baf------2</link>
            <guid isPermaLink="false">https://medium.com/p/3274f0ff947d</guid>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Demo]]></dc:creator>
            <pubDate>Wed, 11 Apr 2018 19:27:45 GMT</pubDate>
            <atom:updated>2018-04-11T19:27:45.046Z</atom:updated>
            <content:encoded><![CDATA[<p>Operating system is a core topic in computer science and it is one of those topics every software developer must have a basic understanding of it works. Operating system is aprogram that acts as an intermediary between a user of a computer and the computer hardware.</p><p>There are many experts answer with huge explanations for the question about operating system. I will try to explain it as simple as possible.</p><p>Assume hardware as a car and operating system as a driver and yourself as the passenger. You are just going to tell him the destination and the driver knows how to start, when to accelerate, when to change the gear, when to apply brakes, how to reach destination faster.</p><p>This is what actually happens, you just instruct the computer to do something through user-interface of the application and the operating system know how to start the process, what are the resources required, how to use ram efficiently, how to complete the process faster, etc.</p><p>Main functions of Operating System are,</p><ul><li>managing the resources (memory, registers, I/O devices) efficiently.</li><li>allocating the processor for different processes.</li><li>reading and writing data from memory.</li><li>managing application software’s and resolving if some error occurs during process.</li></ul><p>So you may have a Lamborghini (high specification hardware) but without driver (Operating System) it is just a show piece.</p><h4>Kernel</h4><p>Kernel the most important part of the software collection called OS. It is the program that does all the heavy lifting in an operating system. It handles the hardware, timing, peripherals, memory, disks, user access and everything that you do on a computer. It decides when a software should run and what should be the permissions given to it. It makes sure that no program access memory that do not belong to it and that no program causes other programs to crash. It divides the time up for processes to use the processor and almost a hundred more duties.</p><p>Then we have something called the shell. A shell is the part of an OS that you as a user interact with. It is a interface created so that a user can communicate with the Kernel. Command line and GUI shells exist. The combination of these and few other software are together called the OS</p><p>Kernel is the one program running at all times on the computer (without it, you wouldn’t have an OS)</p><h4>Firmware</h4><p>Firmware, operating system, kernel… these are some common terminologies that an embedded system developer runs in to — a lot. For explaining clearly the difference between these, lets first explain the components in an embedded device or even a general purpose computer.</p><p>For simplicity, we can imagine a computer as a system consisting of CPU and a variety of peripheral devices. All the user programs run on CPU which a powerful general purpose execution engine, and the function that it does is totally defined by the program being executed. Now consider the case of peripheral devices, they will have a dedicated function, such as:</p><ul><li>eMMC or similar secondary storage — managing of blocks, interpreting eMMC command sent from host, controlling the read-write operations etc.</li><li>Touch screen controller — to interpret commands from host; read the x &amp; y coordinates where user has touched; send interrupt to host on identifying touch event etc.</li><li>GPUs (available in in System-on-Chips — SoCs) — manage the command ring-buffer between host CPU and GPU; interpret and execute the commands send from host via ring buffer; handle the buffers mapped; signalling completion of command execution(fences) etc.</li><li>BIOS (legacy) — to start, configure and initiate the execution of boot loader from boot device when computer is started.</li></ul><p>For providing or fulfilling these functionality, the peripheral may have a <strong>small micro-controller</strong>(in case of ones with TSP controller, eMMC controller etc.) — in case of GPU it will be <strong>multi-core execution engine</strong>. All of which will have a CPU of varying capability.</p><p>As it is with all CPUs, it requires instructions to execute and perform its required function. It <strong>doesn’t need capabilities like :</strong></p><ul><li>multi-tasking,</li><li>advanced interrupt handling,</li><li>segmentation &amp; paging, etc.</li></ul><p>Hence it will be a very minimal software package just enough to complete its intended functionality — <strong>which is called a FIRMWARE.</strong></p><p>A Firmware:</p><ul><li>usually resides in ROM(Read-only-memory) in case of self-contained devices. They will start execution in-place(from ROM itself by the micro-controller) when device is powered on.</li><li>Sometimes, it might be loaded to a small RAM — if device/controller is having one</li><li>Is usually frozen during production, but in some cases, it can be upgraded via special tools (if it is burned in to EEPROM or NOR flash)</li><li>There are cases in which the firmware resides in other secondary storage devices(Hard disk, SD card, etc.). The Host CPU will load the firmware on the peripheral device via some BUS(I2C, SPI etc.) after power-on &amp; reset of peripheral devices(happens during boot up). After which firmware will start execution in the peripheral device. This happens in most of the modern GPUs embedded in SoCs Upgrading of firmware is quite straight forward in these kind of systems.</li></ul><p>An Operating System<strong> </strong>is on the other hand</p><ul><li>Provides a <strong>Kernel </strong>to interact with the underlying hardware components &amp; associated <strong>userspace</strong> (programs, libc, libraries etc.) for user.</li><li>It provide (via kernel) standard functionality like multi-user, multi-programming, security, device drivers etc. which is needed to exploit the underlying hardware.</li></ul><p>Basically firmware, kernel, operating system are abstractions intended at various applications.</p><h4>Interrupt</h4><p>The main function of the “interrupt”, this makes the multiprogramming possible. The CPU is always much more quicker, than the input / output devices. So when you start an I/O operation, you don’t have to wait the finish, you can do other work meanwhile. When I/O has finished, sends an interrupt signal, and program counter gets the address of an interrupt handler routine. What happens, if there is no I/O operation? For this case there is a special device, the “interval timer”. This time to time gives an interrupt. The operating system handle this parallel operations. There are different algorithms for this. And a nice field of systems programming. Also there are software interrupts (exceptions) in case some critical software event. ( for example divide by zero, or hurt memory protection, etc. )</p><p>An interrupt in an operating system is a kind of event generated either internally or externally that triggers a specific sequence of events. It might be easier to explain on a smaller level:</p><p>Hardware interrupts come from outside the operating system. On a computer it may come from a mouse click, hard disk, or even some form of failure. These are called Asynchronous interrupts because it doesn’t necessarily happen after another operation on the computer has finished and isn’t reliant on the computer’s timing. An asynchronous interrupt can happen at any time. On our small system, let’s say you have a microcontroller with one button and one LED attached. You have an interrupt that will turn on and off the LED set to trigger when that button is pushed.</p><p>When the button is pushed, it will set a flag somewhere in the microcontroller that essentially sends a direct message to the microcontroller that says “Hey, an event happened!” and it gives the location of event, in this case it is the input that the button is. That location points to a specific place in program memory where the actions that you want to happen occur. In this case, the location at which the Interrupt Vector points is a function that toggles the LED on or off.</p><p>This jump can happen anywhere in the program and when it does, the computer writes to memory somewhere the exact spot it was in so it can return to whatever it was doing after the interrupt occurred.</p><p>A synchronous interrupt — or software interrupt (also sometimes called an ‘exception’) — happens when the processor faces some strange or otherwise unexpected behaviour when processing the software. These are considered syncronous because they occur within the timing of the computer and are not dependent on any eternal sources to occur.</p><p>Interrupt Handling :</p><ul><li>The operating system preserves the state of the CPU by storing <strong>registers</strong> and the <strong>program counter</strong></li><li>Incoming interrupts are disabled (prevent lost interrupts)</li><li>Which device?</li></ul><p>Polling (no identity known)</p><p>Vectored (sends identity along)</p><ul><li>Separate segments of code determine what action should be taken for each type of interrupt</li></ul><p>Interrupt Timeline :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*yaQxAgc8pHT11DwDFH0mCw.png" /><figcaption><strong>Interrupt Timeline</strong></figcaption></figure><h4>Operating System Structure</h4><p>An operating system might have many structure. According to the structure of the operating system; operating systems can be classified into many categories.<br>Some of the main structures used in operating systems are:</p><ol><li>Simple Structure</li></ol><p>It is the oldest architecture used for developing operating system. Only one or two levels of code. When DOS was originally written its developers had no idea how big and important it would eventually become. It was written by a few programmers in a relatively short amount of time, without the benefit of modern software engineering techniques, and then gradually grew over time to exceed its original expectations. It does not break the system into subsystems, and has no distinction between user and kernel modes, allowing all programs direct access to the underlying hardware. ( Note that user versus kernel mode was not supported by the 8088 chip set anyway, so that really wasn’t an option back then. )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*IW9iiIH2ZsK6P4ijJXpSRg.png" /><figcaption><strong>MS-DOS Layer Structure</strong></figcaption></figure><p>The original UNIX OS used a simple layered approach, but almost all the OS was in one big layer, not really breaking the OS down into layered subsystems:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/0*RDLr78NhhxQCdzhe.jpg" /><figcaption><strong>Traditional UNIX system structure</strong></figcaption></figure><p>2. Layered Architecture of operating system</p><p>The layered Architecture of operating system was developed in 60’s in this approach, the operating system is broken up into number of layers. The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0) is the hardware, the highest (layer N) is the user interface.With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*vG8SdXxCA8ARG7Itd8ZiIw.png" /><figcaption><strong>Layered Operating System</strong></figcaption></figure><p>The first layer can be debugged without any concern for the rest of the system. It user basic hardware to implement this function once the first layer is debugged., it’s correct functioning can be assumed while the second layer is debugged &amp; soon . If an error is found during the debugged of particular layer, the layer must be on that layer, because the layer below it already debugged. Because of this design of the system is simplified when operating system is broken up into layer.</p><ul><li>Another approach is to break the OS into a number of smaller layers, each of which rests on the layer below it, and relies solely on the services provided by the next lower layer.</li><li>This approach allows each layer to be developed and debugged independently, with the assumption that all lower layers have already been debugged and are trusted to deliver proper services.</li><li>The problem is deciding what order in which to place the layers, as no layer can call upon the services of any higher layer, and so many chicken-and-egg situations may arise.</li><li>Layered approaches can also be less efficient, as a request for service from a higher layer has to filter through all lower layers before it reaches the HW, possibly with significant processing at each step.</li></ul><p>Os/2 operating system is example of layered architecture of operating system another example is earlier version of Windows NT.<br> The main disadvantage of this architecture is that it requires an appropriate definition of the various layers &amp; a careful planning of the proper placement of the layer. Lower levels independent of upper levels.</p><p>3. Microkernel</p><p>OS built from many user-level processes.</p><ul><li>The basic idea behind micro kernels is to remove all non-essential services from the kernel, and implement them as system applications instead, thereby making the kernel as small and efficient as possible.</li><li>Most microkernels provide basic process and memory management, and message passing between other services, and not much more.</li><li>Security and protection can be enhanced, as most services are performed in user mode, not kernel mode.</li><li>System expansion can also be easier, because it only involves adding more system applications, not rebuilding a new kernel.</li><li>Mach was the first and most widely known microkernel, and now forms a major component of Mac OSX.</li><li>Windows NT was originally microkernel, but suffered from performance problems relative to Windows 95. NT 4.0 improved performance by moving more services into the kernel, and now XP is back to being more monolithic.</li><li>Another microkernel example is QNX, a real-time OS for embedded systems.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/0*KvyU73bDD2yWKxVi.jpg" /><figcaption><strong><em>Architecture of a typical microkernel</em></strong></figcaption></figure><p>4. Modular</p><p>Core kernel with Dynamically loadable modules.</p><ul><li>Modern OS development is object-oriented, with a relatively small core kernel and a set of <strong><em>modules</em></strong> which can be linked in dynamically. See for example the Solaris structure, as shown in Figure 2.13 below.</li><li>Modules are similar to layers in that each subsystem has clearly defined tasks and interfaces, but any module is free to contact any other module, eliminating the problems of going through multiple intermediary layers, as well as the chicken-and-egg problems.</li><li>The kernel is relatively small in this architecture, similar to microkernels, but the kernel does not have to implement message passing since modules are free to contact each other directly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/0*adQtDPjsE9zsJ8r9.jpg" /><figcaption><strong>Solaris loadable modules</strong></figcaption></figure><p>5. Hybrid System</p><p>Most OSes today do not strictly adhere to one architecture, but are hybrids of several.</p><p><em>MAC OS</em></p><ul><li>The Max OSX architecture relies on the Mach microkernel for basic system management services, and the BSD kernel for additional services. Application services and dynamically loadable modules ( kernel extensions ) provide the rest of the OS functionality:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/0*4H_81olEwFSPCta6.jpg" /><figcaption><strong>The Mac OS X structure</strong></figcaption></figure><p><em>iOS</em></p><ul><li>The iOS operating system was developed by Apple for iPhones and iPads. It runs with less memory and computing power needs than Max OS X, and supports touchscreen interface and graphics for small screens:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/0*warjPY9Z7XTXhw0Q.jpg" /><figcaption><strong>Architecture of Apple’s iOS</strong></figcaption></figure><p><em>Android</em></p><ul><li>The Android OS was developed for Android smartphones and tablets by the Open Handset Alliance, primarily Google.</li><li>Android is an open-source OS, as opposed to iOS, which has lead to its popularity.</li><li>Android includes versions of Linux and a Java virtual machine both optimized for small platforms.</li><li>Android apps are developed using a special Java-for-Android development environment.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/0*HWVFPzQ2oOw_Da3P.jpg" /><figcaption><strong>Architecture of Google’s Android</strong></figcaption></figure><h4>Operating system components</h4><p>An operating system provides the environment within which programs are executed. To construct such an environment, the system is partitioned into small modules with a well-defined interface. The design of a new operating system is a major task. It is very important that the goals of the system be will defined before the design begins. The type of system desired is the foundation for choices between various algorithms and strategies that will be necessary. A system as large and complex as an operating system can only be created by partitioning it into smaller pieces. Each of these pieces should be a well defined portion of the system with carefully defined inputs, outputs, and function. Obviously, not all systems have the same structure. However, many modern operating systems share the system components outlined below.</p><ol><li>Process management</li></ol><p>The CPU executes a large number of programs. While its main concern is the execution of user programs, the CPU is also needed for other system activities. These activities are called processes. A process is a program in execution. Typically, a batch job is a process. A time-shared user program is a process. A system task, such as spooling, is also a process. For now, a process may be considered as a job or a time-shared program, but the concept is actually more general.</p><p>In general, a process will need certain resources such as CPU time, memory, files, I/O devices, etc., to accomplish its task. These resources are given to the process when it is created. In addition to the various physical and logical resources that a process obtains when its is created, some initialization data (input) may be passed along. For example, a process whose function is to display on the screen of a terminal the status of a file, say F1, will get as an input the name of the file F1 and execute the appropriate program to obtain the desired information.</p><p>We emphasize that a program by itself is not a process; a program is a passive entity, while a process is an active entity. It is known that two processes may be associated with the same program, they are nevertheless considered two separate execution sequences.</p><p>A process is the unit of work in a system. Such a system consists of a collection of processes, some of which are operating system processes, those that execute system code, and the rest being user processes, those that execute user code. All of those processes can potentially execute concurrently.</p><p>The operating system is responsible for the following activities in connection with processes managed.</p><ul><li>The creation and deletion of both user and system processes</li><li>The suspension are resumption of processes</li><li>The provision of mechanisms for process synchronization</li><li>The provision of mechanisms for deadlock handling</li></ul><p>2. Memory Management</p><p>Memory is central to the operation of a modern computer system. Memory is a large array of words or bytes, each with its own address. Interaction is achieved through a sequence of reads or writes of specific memory address. The CPU fetches from and stores in memory.</p><p>In order for a program to be executed it must be mapped to absolute addresses and loaded in to memory. As the program executes, it accesses program instructions and data from memory by generating these absolute is declared available, and the next program may be loaded and executed.</p><p>In order to improve both the utilization of CPU andthe speed of the computer’s response to its users, several processes must be kept in memory. There are many different algorithms depends on the particular situation. Selection of a memory management scheme for a specific system depends upon many factor, but especially upon the hardware design of the system. Each algorithm requires its own hardware support.</p><p>The operating system is responsible for the following activities in connection with memory management.</p><ul><li>Keep track of which parts of memory are currently being used and by whom.</li><li>Decide which processes are to be loaded into memorywhen memory space becomes available.</li><li>Allocate and deallocate memory space as needed.</li></ul><p>3. Secondary Storage Management</p><p>The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory during execution. Since the main memory is too small to permanently accommodate all data and program, the computer system must provide secondary storage to backup main memory. Most modem computer systems use disks as the primary on-line storage of information, of both programs and data. Most programs, like compilers, assemblers, sort routines, editors, formatters, and so on, are stored on the disk until loaded into memory, and then use the disk as both the source and destination of their processing. Hence the proper management of disk storage is of central importance to a computer system.</p><p>There are few alternatives. Magnetic tape systems are generally too slow. In addition, they are limited to sequential access. Thus tapes are more suited for storing infrequently used files, where speed is not a primary concern.</p><p>The operating system is responsible for the following activities in connection with disk management</p><ul><li>Free space management</li><li>Storage allocation</li><li>Disk scheduling.</li></ul><h4>Operating system-services</h4><p>An Operating System provides services to both the users and to the programs.</p><ul><li>It provides programs an environment to execute.</li><li>It provides users the services to execute the programs in a convenient manner.</li></ul><p>Following are a few common services provided by an operating system −</p><ul><li>Program execution</li><li>I/O operations</li><li>File System manipulation</li><li>Communication</li><li>Error Detection</li><li>Resource Allocation</li><li>Protection</li></ul><p><strong><em>Program Execution</em></strong></p><p>Operating systems handle many kinds of activities from user programs to system programs like printer spooler, name servers, file server, etc. Each of these activities is encapsulated as a process.</p><p>A process includes the complete execution context (code to execute, data to manipulate, registers, OS resources in use). Following are the major activities of an operating system with respect to program management −</p><ul><li>Loads a program into memory.</li><li>Executes the program.</li><li>Handles program’s execution.</li><li>Provides a mechanism for process synchronization.</li><li>Provides a mechanism for process communication.</li><li>Provides a mechanism for deadlock handling.</li></ul><p><strong><em>I/O Operation</em></strong></p><p>An I/O subsystem comprises of I/O devices and their corresponding driver software. Drivers hide the peculiarities of specific hardware devices from the users.</p><p>An Operating System manages the communication between user and device drivers.</p><ul><li>I/O operation means read or write operation with any file or any specific I/O device.</li><li>Operating system provides the access to the required I/O device when required.</li></ul><p><strong><em>File System Manipulation</em></strong></p><p>A file represents a collection of related information. Computers can store files on the disk (secondary storage), for long-term storage purpose. Examples of storage media include magnetic tape, magnetic disk and optical disk drives like CD, DVD. Each of these media has its own properties like speed, capacity, data transfer rate and data access methods.</p><p>A file system is normally organized into directories for easy navigation and usage. These directories may contain files and other directions. Following are the major activities of an operating system with respect to file management −</p><ul><li>Program needs to read a file or write a file.</li><li>The operating system gives the permission to the program for operation on file.</li><li>Permission varies from read-only, read-write, denied and so on.</li><li>Operating System provides an interface to the user to create/delete files.</li><li>Operating System provides an interface to the user to create/delete directories.</li><li>Operating System provides an interface to create the backup of file system.</li></ul><p><strong><em>Communication</em></strong></p><p>In case of distributed systems which are a collection of processors that do not share memory, peripheral devices, or a clock, the operating system manages communications between all the processes. Multiple processes communicate with one another through communication lines in the network.</p><p>The OS handles routing and connection strategies, and the problems of contention and security. Following are the major activities of an operating system with respect to communication −</p><ul><li>Two processes often require data to be transferred between them</li><li>Both the processes can be on one computer or on different computers, but are connected through a computer network.</li><li>Communication may be implemented by two methods, either by Shared Memory or by Message Passing.</li></ul><p><strong><em>Error handling</em></strong></p><p>Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or in the memory hardware. Following are the major activities of an operating system with respect to error handling −</p><ul><li>The OS constantly checks for possible errors.</li><li>The OS takes an appropriate action to ensure correct and consistent computing.</li></ul><p><strong><em>Resource Management</em></strong></p><p>In case of multi-user or multi-tasking environment, resources such as main memory, CPU cycles and files storage are to be allocated to each user or job. Following are the major activities of an operating system with respect to resource management −</p><ul><li>The OS manages all kinds of resources using schedulers.</li><li>CPU scheduling algorithms are used for better utilization of CPU.</li></ul><p><strong><em>Protection</em></strong></p><p>Considering a computer system having multiple users and concurrent execution of multiple processes, the various processes must be protected from each other’s activities.</p><p>Protection refers to a mechanism or a way to control the access of programs, processes, or users to the resources defined by a computer system. Following are the major activities of an operating system with respect to protection −</p><ul><li>The OS ensures that all access to system resources is controlled.</li><li>The OS ensures that external I/O devices are protected from invalid access attempts.</li><li>The OS provides authentication features for each user by means of passwords.</li></ul><h4>Introduction to System Calls</h4><p>To understand system calls, first one needs to understand the difference between <strong>kernel mode</strong> and <strong>user mode</strong> of a CPU. Every modern operating system supports these two modes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/0*EOqhM4lADPCMIfqn.png" /></figure><p><strong>Modes supported by the operating system</strong></p><blockquote>Kernel Mode</blockquote><ul><li>When CPU is in <strong>kernel mode</strong>, the code being executed can access any memory address and any hardware resource.</li><li>Hence kernel mode is a very privileged and powerful mode.</li><li>If a program crashes in kernel mode, the entire system will be halted.</li></ul><blockquote>User Mode</blockquote><ul><li>When CPU is in <strong>user mode</strong>, the programs don’t have direct access to memory and hardware resources.</li><li>In user mode, if any program crashes, only that particular program is halted.</li><li>That means the system will be in a safe state even if a program in user mode crashes.</li><li>Hence, most programs in an OS run in user mode.</li></ul><blockquote>System Call</blockquote><p>In computing, a <strong>system call</strong> is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. A system call is a way for programs to <strong>interact with the operating system</strong>. A computer program makes a system call when it makes a request to the operating system’s kernel. System call <strong>provides</strong> the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and operating system to allow user-level processes to request services of the operating system. System calls are the only entry points into the kernel system. All programs needing resources must use system calls.</p><p>When a program in user mode requires access to RAM or a hardware resource, it must ask the kernel to provide access to that resource. This is done via something called a <strong>system call</strong>.</p><p>When a program makes a system call, the mode is switched from user mode to kernel mode. This is called a <strong>context switch</strong>.</p><p>Then the kernel provides the resource which the program requested. After that, another context switch happens which results in change of mode from kernel mode back to user mode.</p><p>Generally, system calls are made by the user level programs in the following situations:</p><ul><li>Creating, opening, closing and deleting files in the file system.</li><li>Creating and managing new processes.</li><li>Creating a connection in the network, sending and receiving packets.</li><li>Requesting access to a hardware device, like a mouse or a printer.</li></ul><p>In a typical UNIX system, there are around 300 system calls. Some of them which are important ones in this context, are described below.</p><p><strong>Fork()</strong></p><p>The fork() system call is used to create processes. When a process (a program in execution) makes a fork() call, an exact copy of the process is created. Now there are two processes, one being the <strong>parent</strong> process and the other being the <strong>child</strong> process.</p><p>The process which called the fork() call is the <strong>parent</strong> process and the process which is created newly is called the <strong>child</strong> process. The child process will be exactly the same as the parent. Note that the process state of the parent i.e., the address space, variables, open files etc. is copied into the child process. This means that the parent and child processes have identical but physically different address spaces. The change of values in parent process doesn&#39;t affect the child and vice versa is true too.</p><p>Both processes start execution from the next line of code i.e., the line after the fork() call. Let&#39;s look at an example:</p><pre>// example.c<br>#include &lt;stdio.h&gt;<br>void main() <br>{<br>    int val;  <br>    val = fork();   // line A<br>    printf(&quot;%d&quot;, val);  // line B<br>}</pre><p>When the above example code is executed, when <strong>line A</strong> is executed, a child process is created. Now both processes start execution from <strong>line B</strong>. To differentiate between the child process and the parent process, we need to look at the value returned by the fork() call.</p><p>The difference is that, in the parent process, fork() returns a value which represents the <strong>process ID</strong> of the child process. But in the child process, fork() returns the value 0.</p><p>This means that according to the above program, the output of parent process will be the <strong>process ID</strong> of the child process and the output of the child process will be 0.</p><p><strong>Exec()</strong></p><p>The exec() system call is also used to create processes. But there is one big difference between fork() and exec() calls. The fork() call creates a new process while preserving the parent process. But, an exec() call replaces the address space, text segment, data segment etc. of the current process with the new process.</p><p>It means, after an exec() call, only the new process exists. The process which made the system call, wouldn&#39;t exist.</p><p>There are many flavors of exec() in UNIX, one being exec1() which is shown below as an example:</p><pre>// example2.c<br>#include &lt;stdio.h&gt;<br>void main() <br>{<br>    execl(&quot;/bin/ls&quot;, &quot;ls&quot;, 0);      // line A<br>    printf(&quot;This text won&#39;t be printed unless an error occurs in exec().&quot;);<br>}</pre><p>As shown above, the first parameter to the execl() function is the address of the program which needs to be executed, in this case, the address of the <strong>ls</strong> utility in UNIX. Then it is followed by the name of the program which is <strong>ls</strong> in this case and followed by optional arguments. Then the list should be terminated by a NULL pointer (0).</p><p>When the above example is executed, at line A, the <strong>ls</strong> program is called and executed and the current process is halted. Hence the printf() function is never called since the process has already been halted. The only exception to this is that, if the <strong>execl()</strong> function causes an error, then the printf() function is executed.</p><p><strong>Services Provided by System Calls :</strong></p><ol><li>Process creation and management</li><li>Main memory management</li><li>File Access, Directory and File system management</li><li>Device handling(I/O)</li><li>Protection</li><li>Networking, etc.</li></ol><p><strong>Types of System Calls :</strong> There are 5 different categories of system calls –</p><ol><li>Process control<strong>:</strong> end, abort, create, terminate, allocate and free memory.</li><li>File management<strong>:</strong> create, open, close, delete, read file etc.</li><li>Device management</li><li>Information maintenance</li><li>Communication</li></ol><p><strong>Examples of Windows and Unix System Calls –</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*2LMO4V7DixHm-kOX.jpg" /><figcaption><strong>Examples of Windows and Unix System Calls</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3274f0ff947d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>