Bab 1: Pendahuluan
1.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Bab1: Pendahuluan Fungsi sistem operasi Organisasi Sistem Komputer Arsitektur Sistem Komputer Struktur sistem operasi Operasi pada sistem operasi Manajemen Proses Manajemen Memory Manajemen Penyimpanan Data (Storage) Proteksi dan Sekuritas Distributed Systems Special-Purpose Systems Computing Environments
1.3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Tujuan Bab ini bertugas memberikan penjelasan secara umum untuk tiap komponen-komponen sistem operasi Bab ini bertugas memberikan penjelasan tentang organisasi sistem komputer
1.4 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Apa itu Operating System? Sebuah program yang bertugas sebagai interface antara user dengan hardware komputer Tujuan Operating system : Mengeksekusi program milik user dan memudahkan user untuk menyelesaikan masalah dengan mudah Membuat sistem komputer mudah untuk digunakan Menggunakan hardware komputer dengan efisien
1.5 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Struktur Sistem Komputer Computer system dapat dibagi menjadi 4 komponen Hardware – sebagai resource untuk komputasi dasar CPU, memory, I/O devices Operating system Controls and coordinates use of hardware among various applications and users Program aplikasi – define the ways in which the system resources are used to solve the computing problems of the users Word processors, compilers, web browsers, database systems, video games User manusia, mesin, komputer lain
1.6 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Empat Komponen Sistem Komputer
1.7 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Definisi Operating System OS bertugas melakukan alokasi resource Melakukan manajemen resource Mengambil keputusan saat terjadi konflik request agar resource dapat digunakan secara fair dan efisien OS adalah control program Artinya, OS mengendalikan eksekusi program-program untuk mencegah error dan pemakaian komputer yang tidak bijak
1.8 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Definisi Operating System (Cont.) Tidak ada definisi yang pasti mengenai sistem operasi Tiap sistem operasi bergantung pada pembuat sistem operasi tersebut Akibatnya, sistem operasi bervariasi Program yang terus beroperasi pada hardware komputer disebut kernel. Sementara program-program lain adalah system program (yang membentuk sistem operasi, seperti : disk defragmenter, printing, melihat isi directory, dll ). Sisanya adalah program aplikasi. (game, word, dll)
1.9 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Kernel Kernel adalah program yang bertugas mengatur input/output request dari aplikasi/user menuju resource dari komputer, yaitu : CPU, memory, I/O, atau devais lainnya dari komputer
1.10 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Computer System Organization Computer-system operation Satu atau lebih CPUs, device controllers terkoneksi lewat bus untuk dapat mengakses shared memory Eksekusi instruksi CPU dan devais yang terus-menerus membutuhkan cycles memory
1.11 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Operasi pada Sistem Komputer I/O devices dan CPU bekerja sama secara terus-menerus Tiap device controller adalah hardware yang bertugas untuk tiap tipe devais Tiap device controller memiliki local buffer. CPU memindahkan data dari/ke main memory dari/ke local buffers Device controller memberi tahu CPU bahwa tugasnya untuk mentransfer request ke local buffer telah selesai dengan menggunakan interrupt.
1.12 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Device I/O address
1.13 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 13 Operating systems dikendalikan oleh interrupt Interrupt adalah request layanan dari CPU Contoh interrupt : Mouse moved. Disk drive at sector/track position(old days). Keyboard key pressed. Printer out of paper. Video card wants memory access. Modem sending or receiving. USB scanner has data. Tiap interrupt ini membutuhkan penanganan yang berbeda, tergantung jenis dan asal interrupt.Interrupts
1.14 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Hardware & Software Interrupts Interrupt bisa dilakukan hardware lewat the system bus (e.g., mouse moved) Interrupt bisa dilakukan software (e.g., system call for I/O, trap for division by zero)
1.15 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Interrupt Timeline
1.16 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts I/O Structure After I/O starts, control returns to user program only upon I/O completion. Wait instruction idles the CPU until the next interrupt Wait loop (contention for memory access). At most one I/O request is outstanding at a time, no simultaneous I/O processing. After I/O starts, control returns to user program without waiting for I/O completion. System call – request to the operating system to allow user to wait for I/O completion. Device-status table contains entry for each I/O device indicating its type, address, and state. Operating system indexes into I/O device table to determine device status and to modify table entry to include interrupt.
1.17 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Scheduling I/O Scheduling I/O requests can greatly improve overall efficiency. Priorities can also play a part in request scheduling. The classic example is the scheduling of disk accesses, as discussed in detail in chapter 12. Buffering and caching can also help, and can allow for more flexible scheduling options. On systems with many devices, separate request queues are often kept for each device
1.18 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Tabel Device-Status
1.19 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Direct Memory Access Direct Memory Access: a device driver assigns a specific memory segment to the device controller device controller can transfer an entire block of data directly to/from main memory without CPU intervention. only one interrupt is generated per block, rather than the one interrupt per byte For example : a sound card may need to access data stored in the computer's RAM, but since it can process the data itself, it may use DMA to bypass the CPU. Video cards that support DMA can also access the system memory and process graphics without needing the CPU.
1.20 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Storage Structure Main memory – only large storage media that the CPU can access directly. Secondary storage – extension of main memory that provides large nonvolatile storage capacity. Magnetic disks – rigid metal or glass platters covered with magnetic recording material Disk surface is logically divided into tracks, which are subdivided into sectors. The disk controller determines the logical interaction between the device and the computer.
1.21 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 21 Memory is organized in a hierarchy tradeoffs: speed, cost, volatility primary memory fast, expensive, volatile data is stored in electronic circuitry only storage CPU can access directly Secondary memory slow, cheap, permanent data is stored magnetically or optically or "physically" can store massive amounts of inactive data, must be copied to primary memory to be accessed Storage structure secondary memory primary memory cpu
1.22 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Caching Caching – copying information into faster storage system; main memory can be viewed as a last cache for secondary storage. Important principle, performed at many levels in a computer Web cache, dns-cache, etc Information in use copied from slower to faster storage temporarily Faster storage (cache) checked first to determine if information is there If it is, information used directly from the cache (fast) If not, data copied to cache and used there Cache smaller than storage being cached Cache management important design problem Cache size and replacement policy
1.23 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Performance of Various Levels of Storage Movement between levels of storage hierarchy can be explicit or implicit
1.24 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Migration of Integer A from Disk to Register Multitasking environments must be careful to use most recent value, not matter where it is stored in the storage hierarchy Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most recent value in their cache Distributed environment situation even more complex Several copies of a datum can exist Various solutions covered in Chapter 17 CPU
1.25 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Operating System Structure Multiprogramming digunakan untuk meningkatkan efisiensi Single user CPU and I/O devices busy at all times Multiprogramming organizes jobs (code and data) so CPU always has one to execute A subset of total jobs in system is kept in memory One job selected and run via job scheduling When it has to wait (for I/O for example), OS switches to another job Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing Response time should be < 1 second Each user has at least one program executing in memory process If several jobs ready to run at the same time CPU scheduling If processes don’t fit in memory, swapping moves them in and out to run Virtual memory allows execution of processes not completely in memory
1.26 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Memory Layout for Multiprogrammed System
1.27 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Time sharing
1.28 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Operating-System Operations Interrupt dilakukan oleh hardware Software error atau request menyebabkan terjadinya exception atau trap Division by zero, request for operating system service Other process problems include infinite loop, processes modifying each other or the operating system Dual-mode operation allows OS to protect itself and other system components User mode and kernel mode Mode bit provided by hardware Provides ability to distinguish when system is running user code or kernel code Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user
1.29 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts System calls All operating systems provides some mechanism to request services from the kernel. This service request points are called “system calls” In Linux system, there is an interface layer between the user space and kernel space. This layer consists of library made up of functions that communicate between normal user applications and the Kernel. This implementation of C library is called libc/glibc. This provides wrapper functions for the system calls. System calls are implemented using software interrupt or trap.interrupt trap System call transfer control to the operating system. It sets the system call number, the C arguments into the general registers and then executes some machine instruction that generates a software interrupt in the kernel.
1.30 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts System Call
1.31 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Process Management Proses adalah program yang berjalan. Proses merupakan bagian dari system. Jika program dapat dikatakan sebagai passive entity, process dikatakan sebagai active entity. Process membtuhkan resource untuk melakukan tugasnya (task) CPU, memory, I/O, files Initialization data Penghentian atau terminasi proses akan mengembalikan resource yang digunakan sebelumnya Lab : Matikan seluruh aplikasi di komputer anda Buka task manager, klik show all user process Coba klik start, buka calculator dan jalankan task manager Lihat entry calculator =>aplikasi proses 1 Buka calculator lagi dan lihat di task manager Lihat entry calculator => aplikasi proses 2
1.32 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Process Management Activities Sistem operasi bertanggung jawab untuk aktivitas manajemen proses : Menciptakan dan menghapus proses user dan proses sistem Menghentikan sementara dan meneruskan processes Menyediakan mekanisme untuk process synchronization Menyediakan mekanisme untuk process communication Menyediakan mekanisme untuk penanganan deadlock Deadlock
1.33 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Memory Management Semua data disimpan dalam memory sebelum dan sesudah processing Semua instruksi disimpan dalam memory sebelum dieksekusi Memory management bertugas menentukan isi di dalam memory agar : Mengoptimalkan utilisasi CPU dan memaksimalkan respon komputer terhadap user. Aktivitas yang dilakuka manajemen Memory Melakukan tracking bagian memory mana yang sedang dipakai dan oleh siapa Menentukan instruksi dan data mana yang keluar masuk memory Mengalokasikan dan dealokasi memory space sesuai kebutuhan
1.34 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Storage Management OS provides uniform, logical view of information storage Abstracts physical properties to logical storage unit - file Each medium is controlled by device (i.e., disk drive, tape drive) Varying properties include access speed, capacity, data- transfer rate, access method (sequential or random) File-System management Files usually organized into directories Access control on most systems to determine who can access what OS activities include Creating and deleting files and directories Primitives to manipulate files and dirs Mapping files onto secondary storage Backup files onto stable (non-volatile) storage media
1.35 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Mass-Storage Management Usually disks used to store data that does not fit in main memory or data that must be kept for a “long” period of time. Proper management is of central importance Entire speed of computer operation hinges on disk subsystem and its algorithms OS activities Free-space management Storage allocation Disk scheduling Some storage need not be fast Tertiary storage includes optical storage, magnetic tape Still must be managed Varies between WORM (write-once, read-many-times) and RW (read- write)
1.36 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts I/O Subsystem Salah satu motivasi pemakaian OS adalah menghindarkan user dari interaksi algnsung dengan devais I/O subsystem bertanggung jawab untuk Manajemen memory dari I/O termasuk diantaranya buffering (penyimpanan data dari satu proses sebelum ditransfer ke proses lain), caching (menyimpan sebagian data untuk dalam storage yg lebih cepat demi peningkatan performansi ) seperti pada : memory caching, disk caching, web caching(used in browser), dll spooling (mengurutkan pekerjaan satu dengan yg lain, seperti pada printer, mail ) General device-driver interface Drivers for specific hardware devices
1.37 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Proteksi dan Security Proteksi – mekanisme untuk mengontrol akses proses atau user any mechanism for controlling access of processes or users to resources defined by the OS Security – defense of the system against internal and external attacks Huge range, including denial-of-service, worms, viruses, identity theft, theft of service Systems generally first distinguish among users, to determine who can do what User identities (user IDs, security IDs) include name and associated number, one per user User ID then associated with all files, processes of that user to determine access control Group identifier (group ID) allows set of users to be defined and controls managed, then also associated with each process, file Privilege escalation allows user to change to effective ID with more rights
1.38 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Computing Environments Traditional computer Blurring over time Office environment PCs connected to a network, terminals attached to mainframe or minicomputers providing batch and timesharing Now portals allowing networked and remote systems access to same resources Home networks Used to be single system, then modems Now firewalled, networked
1.39 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Computing Environments (Cont.) Client-Server Computing Dumb terminals supplanted by smart PCs Many systems now servers, responding to requests generated by clients Compute-server provides an interface to client to request services (i.e. database) File-server provides interface for clients to store and retrieve files
1.40 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Peer-to-Peer Computing Another model of distributed system P2P does not distinguish clients and servers Instead all nodes are considered peers May each act as client, server or both Node must join P2P network Registers its service with central lookup service on network, or Broadcast request for service and respond to requests for service via discovery protocol Examples include Napster and Gnutella
1.41 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Web-Based Computing Web has become ubiquitous PCs most prevalent devices More devices becoming networked to allow web access New category of devices to manage web traffic among similar servers: load balancers Use of operating systems like Windows 95, client-side, have evolved into Linux and Windows XP, which can be clients and servers
1.42 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Latihan 1. Apa yang dimaksud kernel, system program dan aplikasi. Beri contohnya ! 2. Apa yang dimaksud : System proses Aplikasi proses Service
1.43 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 3. Apa fungsi uname –r dan uname -v $uname –r : pae $uname –v : #1 SMP Debian deb7ue Bagaimana kita mengetahui kernel bersifat stabil atau tidak ?
1.44 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 4. Apa fungsi DMA dan bagaimana DMA beroperasi 5. Terangkan beberapa terminologi berikut : 1. Batch system 2. Real time system 3. Time sharing system 4. Multi programming system 5. Distributed system
1.45 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts
End of Chapter 1
1.47 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts
1.48 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 6 langkah untuk melakukan instruksi pada sistem komputer The main purpose of a CPU is to execute instructions. We've already seen some simple examples of instructions, i.e., add and addi. The CPU executes the binary representation of the instructions, i.e., machine code. Since programs can be very large, and since CPUs have limited memory, programs are stored in memory (RAM). However, CPUs do its processing on the CPU. So, the CPU must copy the instruction from memory to the CPU, and once it's in the CPU, it can execute it. The PC is used to determine which instruction is executed, and based on this execution, the PC is updated accordingly to the next instruction to be run. Essentially, a CPU repeatedly fetches instructions and executes them. These are the six steps to executing an instruction. Not every instruction goes through every step. However, we label each step so that you can be aware they exist.
1.49 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 2 Decode Instruction and Fetch Operands In the second step, the bits used for the opcode (and function, for R-type instructions) are used to determine how the instruction should be executed. This is what is meant by "decoding" the instruction. Recall that operands are arguments to the assembly instruction. However, since R-type and I-type instructions both use registers, and those registers are in specific locations of the instruction, we can begin to fetch the values within the registers at the same time we are decoding.
1.50 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 3 Perform ALU Operations The ALU has two 32-bit data inputs. It has a 32-bit output. The purpose of the ALU is to perform a computation on the two 32-bit data inputs, such as adding the two values. There are some control bits on the ALU. These control bits specify what the ALU should do. For example, they may specify an addition, or a subtraction, or a bitwise AND. Where do the input values of the ALU come from? Recall that an instruction stores information about its operands. In particular, it encodes registers as 5-bit UB numbers. These register encodings are sent to the register file as inputs. The register file then outputs the 32-bit values of these registers. These are the sent as inputs to the ALU.
1.51 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 4 Memory Access (for load/store) There are only two kind of instructions that access memory: load and store. load copies a value from memory to a register. store copies a register value to memory. Any other instruction skips this step.
1.52 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 5. Store ALU result to register file At this point, the output of the ALU is written back to the register file. For example, if the instruction was: add $r2, $r3, $r4 then the result of adding the contents of $r3 to the contents of $r4 would be stored back into $r2. The result could also be due to a load from memory. Some instructions don't have results to store. For example, branch and jump instructions do not have any results to store.
1.53 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts 6 Update PC Finally, we need to update the program counter. Typically, we perform the following update: PC <- PC + 4 Recall that PC holds the current address of the instruction to be executed. To update it means to set the value of this register to the next instruction to be executed. Unless the instruction is a branch or jump, the next instruction to execute is the next instruction in memory. Since each instruction takes up 4 bytes of memory, then the next address in memory is PC + 4, which is the address of the current instruction plus 4. The PC might change to some other address if there is a branch or jump.
1.54 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Ketika interrupt diterima, CPU harus 1. save the address of the interrupted instruction di register dan program counter 2. disable (or queue) incoming interrupts while processing this one 3. transfer control to the appropriate interrupt service routine this is usually done via an interrupt vector (table of addresses for interrupt service routines), stored in first ~100 memory locations 4. after processing the interrupt, enable incoming interrupts 5. restore interrupted instruction & resume processing
1.55 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts
1.56 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Interrupt Vector Table
1.57 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Interrupt controller
1.58 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Computer Startup BIOS : bertugas menyimpan informasi ttg hardware komputer Suatu program kecil yang terletak di chip motherboard berguna untuk mengatur dan mengontrol hardware komputer sebelum sistem operasi diload. BOOTLOADER Berada di BIOS Bootloader adalah aplikasi pertama yang dijalankan bios sesaat setelah booting. Bootloader akan meload kernel yang menjalankan sistem operasi. Proses ini disebut juga sebagai bootstrap Setelah meload kernel, boot loader akan mengecek HD, untuk mencari partisi boot
1.59 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Boot program diload Disimpan di hard disk Melakukan inisialisasi pada semua aspek sistem komputer Setelah itu mulai melakukan loading terhadap kernel sistem operasi dan mulai beroperasi