Sistem Operasi 3 Process Konsep Proses Proses adalah
- Slides: 43
Sistem Operasi 3 “Process”
Konsep Proses • Proses adalah suatu program yang sedang dieksekusi – Harus dijalankan secara sekuensial • Suatu proses terdiri dari: – Program counter • Tempat untuk menyimpan alamat suatu proses yang akan dieksekusi selanjutnya – Stack • Tempat penyimpanan temporary data yang dibutuhkan selama program dieksekusi – Data section • Berisi variabel global dari suatu proses
Process in Memory
Status Proses • New: pada saat proses pertama kali dibuat • Running: pada saat proses sedang dieksekusi • Waiting: proses menunggu suatu event lain (contoh: proses I/O) • Ready: proses siap untuk diekseskusi • Terminated: pada saat proses sudah selesai dieksekusi
Diagram of Process State
Program Control Block • Setiap proses direpresentasikan kedalam sistem operasi oleh PCB • PCB meliputi informasi yang berhubungan dengan proses: – Process state – Program counter – CPU registers – CPU scheduling information – Memory-management information – Accounting information – I/O status information
Process Control Block (PCB)
Penjadwalan Antrian Proses • job queue : ketika proses memasuki CPU • ready queue : proses yang hidup pada memori utama, siap dan menunggu untuk di-eksekusi • device queue : bila proses tersebut menunggu peralatan I/O tertentu • Setiap proses akan berpindah dari satu antrian ke antrian lain
Ready Queue And Various I/O Device Queues
Representation of Process Scheduling
Penjadwal Antrian • Long-term scheduler (or job scheduler): menentukan proses mana yang harus dimasukkan ke dalam ready queue. • Short-term scheduler (or CPU scheduler): menentukan proses mana yang selanjutnya akan dieksekusi dan segera mengalokasikan CPU (masuk ke job queue)
Scheduler • Short-term scheduler lebih sering dipanggil (hanya dalam waktu millisecond). • Long-term scheduler jarang dipanggil (dalam hitungan detik, menit). • Proses dapat juga dibagi atas 2 macam : – I/O-bound process – menghabiskan waktu lebih banyak untuk mengerjakan I/O daripada di CPU (short CPU bursts) – CPU-bound process – jarang melakukan permintaan I/O, menggunakan lebih banyak waktunya di CPU (long CPU bursts)
Context Switch • Pada saat CPU beralih ke proses lain, sistem harus menyimpan state dari proses lama dan mengambil state dari proses yang baru. • Tugas ini dilakukan oleh context switch • Context-switch time is overhead; the system does no useful work while switching • Time dependent on hardware support
CPU Switch From Process to Process
Process Creation • Parent process create children processes – Pada saat menciptakan proses baru, – Dalam bentuk Tree • Generally, process identified and managed via a process identifier (pid) • Resource sharing – Parent and children share all resources – Children share subset of parent’s resources – Parent and child share no resources • Execution – Parent and children execute concurrently – Parent waits until children terminate
Process Creation UNIX examples: - fork system call creates new process -exec system call, used after a fork to replace the process’ memory space with a new program -Contoh: $ find. –name “*. cpp” | wc –l -Di dalam C, menggunakan header <unistd. h, stdlib, errno. h. Z>
Process Termination • Process mengesekusi perintah terakhir dan meminta OS untuk mengapusnya (exit) – Menampilkan data dari child ke parent (via wait) – Sumber daya proses tersebut didealokasi oleh OS • Parent akan men-terminate eksekusi child dengan paksa (abort), karena – Child telah menghabiskan resources – Task yang ditugaskan pada child sudah selesai – Jika parent melakukan exiting • Beberapa OS tidak memperbolehkan child untuk melanjutkan kegiatannya – All children terminated - cascading termination
Interprocess Comunication • Sistem operasi kebanyakan menjalankan program secara simultan (concurrent). • Program yang dijalankan secara simultan itu dapat bekerja sama (coorperating) dengan proses lain ataupun bekerja sendiri (independent)
Alasan Coorperating Process • Information Sharing: menggunakan informasi(resource) yang sama untuk beberapa proses • Computation Speed-up : suatu task tertentu bisa dipecah menjadi beberapa cooperating processes sehingga bisa dikerjakan secara paralel sehingga menjadi lebih cepat selesai • Modularity : pembuatan suatu sistem yang modular dengan memecahkan fungsi-fungsi dari sistem tersebut menjadi beberapa proses atau thread • Convenience : user bisa dengan mudah mengerjakan sesuatu yang berbeda dalam waktu yang sama – Contoh : satu user bisa saja secara bersamaan mengetik dan mengedit serta mencetak suatu halaman tertentu
Communications Models a. Message Passing b. Shared
Produsen dan Konsumer • • Suatu contoh kasus untuk cooperating processes Produsen: memproduksi barang Konsumer: menghabiskan barang Perlu diperhatikan bahwa barang yang diproduksi oleh produsen dan yang dihabiskan oleh konsumer adalah sama • Terdapat 2 macam consumer-producer problem: – Unbounded-buffer: Tidak adanya batas bagi produsen untuk memproduksi barang – Bounded-buffer: adanya suatu batas bagi produsen untuk memproduksi barang • Consumer harus menunggu sampai buffer kosong dan producer harus menunggu sampai buffer penuh
Bounded-Buffer – Shared-Memory Solution • Shared data: #define BUFFER_SIZE 10 typedef struct item{. . . }; item buffer[BUFFER_SIZE]; int in = 0; int out = 0; • Solution is correct, but can only use BUFFER_SIZE-1 elements (statis)
Bounded-Buffer – Producer while (true) { /* Produce an item */ while (((in = (in + 1) % BUFFER SIZE) == out); /* do nothing -- no free buffers */ buffer[in] = item; in = (in + 1) % BUFFER SIZE; }
Bounded Buffer – Consumer while (true) { while (in == out) ; // do nothing -- nothing to consume // remove an item from the buffer item = buffer[out]; out = (out + 1) % BUFFER SIZE; return item; }
Interprocess Communication – Message Passing • IPC melakukan dua operasi: – send(message) – message size fixed or variable – receive(message) • Jika P dan Q ingin berkomunikasi, mereka harus: – establish a communication link between them – exchange messages via send/receive • Implementation of communication link – physical (e. g. , shared memory, hardware bus) – logical (e. g. , logical properties)
Direct Communication • Processes harus memanggil masing-masing: – send (P, message) – send a message to process P – receive(Q, message) – receive a message from process Q • Properties of communication link – Links dibentuk secara otomatis – Sebuah link diasosiasikan dengan suatu hubungan sepasang proses – Antara setiap pasang pasti memiliki tepat satu link – The link bisa unidirectional, tapi biasanya bi-directional
Indirect Communication • Messages diarahkan diterima dari mailboxes (atau biasa disebut ports) – Each mailbox has a unique id – Processes dapat berkomunikasi jika mereka saling sharing mailbox • Properties of communication link – Link dibangun jika masing-masing proses saling share mailbox yang umum – Sebuah link dapat diasosiasikan dengan banyak processes – Setiap pasang proses dapat share beberapa communication links – Link bisa unidirectional atau bi-directional
Indirect Communication • Operations – create a new mailbox – send and receive messages through mailbox – destroy a mailbox • Primitives are defined as: send(A, message) – send a message to mailbox A receive(A, message) – receive a message from mailbox A
Indirect Communication • Mailbox sharing – P 1, P 2, and P 3 share mailbox A – P 1, sends; P 2 and P 3 receive – Who gets the message? • Solutions – Memperbolehkan sebuah link untuk diasosikan maksimal 2 proses – Memperbolehkan hanya 1 process dalam satu waktu untuk menerima message – Memperbolehkan system untuk memilih siapa penerimanya. Sender diberitahu siapa receiver yang menerimanya.
Synchronization • Message passing may be either blocking or nonblocking • Blocking is considered synchronous – Blocking send : sender memblok sampai message diterima – Blocking receive : receiver memblok sampai message tersedia • Non-blocking is considered asynchronous – Non-blocking : setelah mengirim, sender melanjutkan kegiatannya, tidak perlu menunggu message diterima – Non-blocking receiver menerima message baik valid ataupun tidak (null)
Buffering • Antrian message yang ditempatkan pada link; diimplementasikan dengan: 1. Zero capacity – 0 messages Sender must wait for receiver 2. Bounded capacity – finite length of n messages Sender must wait if link full 3. Unbounded capacity – infinite length Sender never waits
Communications in Client-Server Systems • Sockets • Remote Procedure Calls • Remote Method Invocation (Java)
Sockets • Sebuah programming interface yang memungkinkan proses untuk saling berkomunikasi ke proses lainya • The socket 161. 25. 19. 8: 1625 refers to port 1625 on host 161. 25. 19. 8 • Communication consists between a pair of sockets
Client - Server
Remote Procedure Calls • Remote procedure call (RPC) mengabstraksikan procedure calls antara processes pada jaringan • Stubs – client-side proxy for the actual procedure on the server • Skeleton – server side proxy • The client-side stub locates the server and marshalls the parameters • The server-side stub receives message, unpacks the marshalled parameters, and peforms the procedure on the server
Remote Method Invocation • Remote Method Invocation (RMI) is a Java mechanism similar to RPCs • RMI allows a Java program on one machine to invoke a method on a remote object
Marshalling Parameters
RMI Layers Java Virtual Machine Client Object Remote Object Stub Skeleton Remote Reference Layer Transport Layer TCP Transport Layer
RMI System Architecture Server Virtual Machine Client Virtual Machine Remote Object Client Skeleton Stub “Fred” Registry Virtual Machine Copyright © 1997 Alex Chaffee Server
RMI Flow 1. Server Creates Remote Object Client Virtual Machine 2. Server Registers Remote Object Client Server Virtual Machine Remote Object 1 Skeleton Stub 2 “Fred” Copyright © 1997 Alex Registry Virtual Chaffee Machine Server
RMI Flow Client Virtual Machine Client Server Virtual Machine Remote 3. Client requests object from Registry Object 4. Registry returns remote reference (and stub gets created) Skeleton Stub 3 4 “Fred” Copyright © 1997 Alex Registry Virtual Chaffee Machine Server
RMI Flow Client Virtual Machine Server Virtual Machine Client Remote Object 5 7 6 Stub Skeleton 5. Client invokes stub method 6. Stub talks to skeleton 7. Skeleton invokes remote object “Fred” method Copyright © 1997 Alex Registry Virtual Chaffee Machine Server
NEXT • Thread
- Konsep, penjadwalan, dan operasi di process sistem operasi
- Konsep sistem operasi manajemen operasi
- Makalah sinkronisasi proses sistem operasi
- Pengaturan proses pada sistem operasi
- Terdapat 5 job yang datang hampir pada saat yang bersamaan
- Konsep dasar sistem operasi
- Windows berbasis
- Apa yang dimaksud dengan sistem operasi jaringan
- Konsep dasar sistem operasi
- Manajemen file pada unix
- Pengertian konsep set adalah.
- Fungsi sistem file
- Liabiliti semasa contoh
- Semaphore sistem operasi adalah
- Kelebihan dan kekurangan gui
- Koordinat yang dipakai dalam sistem operasi linux adalah
- Arsitektur firewall pada sistem operasi linux adalah
- Konsep dasar operasi komputer
- Mengajar dan belajar dalam standar proses pendidikan
- Kelebihan tqm
- Vektor i adalah vektor satuan yang searah dengan sumbu x
- Peta minda sistem komputer
- Peta konsep karakteristik kewirausahaan
- Peran sistem operasi sebagai resources manager
- Sistem operasi ahmat josi
- Alamat tabel sebuah page dalam memori ditunjukkan oleh
- Smopi irigasi net
- Gambarkan skema sistem komputer
- Contoh penjadwalan mundur
- Menerapkan sistem operasi jaringan
- Sistem operasi
- Laporan smopi
- Jelaskan peran sistem operasi sebagai extended machine !
- Modul sistem operasi
- Materi kuliah sistem operasi
- Sinkronisasi sistem operasi
- Makalah keamanan sistem operasi
- Struktur sistem operasi
- Komponen utama arsitektur sistem operasi linux yaitu
- Komponen sistem operasi
- 3 komponen utama sistem operasi
- Sistem operasi dos
- Sistem operasi dos memperkenalkan karakter
- Karakteristik sistem operasi jaringan