sistem operasi 3elearning.amikom.ac.id/index.php/download/materi/...• tt i t dt dibthk tempat...
TRANSCRIPT
Sistem Operasi Sistem Operasi 33
“Process”“Process”Antonius Rachmat C S Kom Antonius Rachmat C S Kom Antonius Rachmat C, S.Kom, Antonius Rachmat C, S.Kom,
M.CsM.Cs
K PK PKonsep ProsesKonsep ProsesProses adalah suatu program yang sedang • Proses adalah suatu program yang sedang dieksekusi (run)– Harus dijalankan secara sekuensial pada CPUj p
• Hal yang dicatat pada Process:– Program counter
T t t k i l t t • Tempat untuk menyimpan alamat suatu proses yang akan dieksekusi selanjutnya
– Stack / HeapT t i t d t dib t hk • Tempat penyimpanan temporary data yang dibutuhkan selama program dieksekusi
– Data sectionB i i i b l l b l d i t • Berisi variabel global dari suatu proses
– Text• Berisi kode programnya
S PS PStatus ProsesStatus Proses• New: pada saat proses pertama kali
dibuat• Running: pada saat proses sedang
dieksekusi• Waiting: proses menunggu suatu event
lain (contoh: proses I/O)lain (contoh: proses I/O)• Ready: proses siap untuk diekseskusi
Terminated: pada saat proses sudah • Terminated: pada saat proses sudah selesai dieksekusi
P C l Bl kP C l Bl kProgram Control BlockProgram Control BlockS ti di t ik k d l • Setiap proses direpresentasikan kedalam sistem operasi oleh PCBPCB li ti i f i b h b • PCB meliputi informasi yang berhubungan dengan proses:
P t t– Process state– Program counter
CPU registers– CPU registers– CPU scheduling information– Memory-management informationMemory management information– Accounting information– I/O status information, etcI/O status information, etc
P j d l A i PP j d l A i PPenjadwalan Antrian ProsesPenjadwalan Antrian Proses• job queue: antrian ketika proses berada
di CPU• ready queue: antrian proses yang hidup
pada memori utama, siap dan menunggu p p gguntuk masuk ke job queue
• device queue: antrian bila proses device queue: antrian bila proses tersebut menunggu peralatan I/O tertentu
• Setiap proses bisa berpindah dari satu • Setiap proses bisa berpindah dari satu antrian ke antrian lain
P j d l A iP j d l A iPenjadwal AntrianPenjadwal 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 ) pyang selanjutnya akan dieksekusi dan segera mengalokasikan CPU (masuk ke g gjob queue)
S h d lS h d lSchedulerSchedulerSho t te m hed le lebih se ing• Short-term scheduler lebih seringdigunakan (hanya dalam waktu millisecond).millisecond).
• Long-term scheduler jarang digunakan (dalam hitungan detik, menit).( g )
• Proses dapat juga dibagi atas 2 macam :– I/O-bound process – menghabiskan waktu
l bih b k t k j k I/O d i d lebih banyak untuk mengerjakan I/O daripada di CPU (short CPU bursts)
– CPU-bound process – jarang melakukan p j gpermintaan I/O, menggunakan lebih banyak waktunya di CPU (long CPU bursts)
C S i hC S i hContext SwitchContext Switch• Pada saat CPU beralih ke proses lain,
sistem harus menyimpan state dari proses lama dan mengambil state dari proses yang baru.
• Kegiatan ini dinamakan context switch• Context-switch time is overhead; the Context switch time is overhead; the
system does no useful work while switchingswitching
• Time dependent on hardware support
Process CreationProcess CreationProcess CreationProcess Creation• Parent process can create children Parent process can create children
processes• Generally, process identified and managed
id ifi ( id)via a process identifier (pid)• Model Resource sharing
P t d hild h ll – Parent and children share all resources– Children share subset of parent’s resources– Parent and child share no resourcesParent and child share no resources
• Model Execution– Parent and children execute concurrentlyParent and children execute concurrently– Parent waits until children terminate
P T i iP T i i M d lM d lProcess TerminationProcess Termination ModelModelP k i i t h t khi d • Process mengesekusi perintah terakhir dan meminta OS untuk mengapusnya (exit)– Sumber daya proses tersebut didealokasi oleh OSSumber 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• Jika parent melakukan exiting– Beberapa OS tidak memperbolehkan child untuk
melanjutkan kegiatannya• All children terminated - cascading
termination
K ik i K ik i Komunikasi antar prosesKomunikasi antar proses• Sistem operasi kebanyakan
menjalankan program secara j p gsimultan (concurrent).
• Program yang dijalankan secara • Program yang dijalankan secara simultan itu dapat bekerja sama ( i ) d l(coorperating) dengan proses lain ataupun bekerja sendiri p j(independent)
Al C i PAl C i PAlasan Coorperating ProcessAlasan Coorperating Process• Information Sharing: menggunakan informasi(resource) • Information Sharing: menggunakan informasi(resource)
yang sama untuk beberapa proses• Computation Speed-up : suatu task tertentu bisa dipecah
menjadi beberapa cooperating processes sehingga bisa menjadi beberapa cooperating processes sehingga bisa dikerjakan secara paralel sehingga menjadi lebih cepat selesai
• Modularity : pembuatan suatu sistem yang modular y p y gdengan memecahkan fungsi-fungsi dari sistem tersebut menjadi beberapa proses atau thread
• Convenience : user bisa dengan mudah mengerjakan t b b d d l kt sesuatu yang berbeda dalam waktu yang sama
– Contoh : satu user bisa saja secara bersamaan mengetik dan mengedit serta mencetak suatu halaman tertentu
Message PassingMessage PassingMessage PassingMessage Passing• IPC melakukan dua operasi:
send(message) message size fixed or – send(message) – message size fixed or variable
– receive(message)receive(message)• Jika P dan Q ingin berkomunikasi, mereka
harus:harus:– establish a communication link between them
exchange messages via send/receive– exchange messages via send/receive• Implementation of communication link
– physical (e.g., shared memory, hardware bus)– logical (e.g., logical properties)
S h i iS h i iSynchronizationSynchronizationM i b ith bl ki • Message passing may be either blocking or non-blocking
• Blocking is considered synchronous• Blocking is considered synchronous– Blocking send : sender memblok sampai message
diterimaBl ki i i bl k i – Blocking receive : receiver memblok sampai message tersedia
• Non-blocking is considered asynchronousg y– Non-blocking : setelah mengirim, sender melanjutkan
kegiatannya, tidak perlu menunggu message diterima– Non-blocking receiver menerima message baik valid – Non-blocking receiver menerima message baik valid
ataupun tidak (null)
B ff iB ff iBufferingBuffering• Antrian message yang ditempatkan
pada link; diimplementasikan p ; pdengan:1 Zero capacity – 0 messages1. Zero capacity 0 messages
Sender must wait for receiver -> no buffer2. Bounded capacity – finite length of n2. Bounded capacity finite length of n
messagesSender must wait if link full
3. Unbounded capacity – infinite length Sender never waits
Communications in ClientCommunications in Client--Server Server Communications in ClientCommunications in Client Server Server SystemsSystems
• Sockets• Remote Procedure Calls (RPC)• Remote Procedure Calls (RPC)• Remote Method Invocation (RMI
J )Java)• .NET Remoting.NET Remoting
S kS kSocketsSocketsS b h i i t f ki k • 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 8161.25.19.8
• Communication consists between a pair of sockets
R P d C llR P d C llRemote Procedure CallsRemote Procedure CallsRemote p o ed e ll (RPC) • Remote procedure call (RPC) mengabstraksikan procedure calls antara processes pada jaringanprocesses pada jaringan
• Stubs – client-side proxy for the actual procedure on the serverp
• 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 unpacks the marshalled parameters, and peforms the procedure on the server
R M h d I iR M h d I iRemote Method InvocationRemote Method InvocationR M h d I i (RMI) i J h i • Remote Method Invocation (RMI) is a Java mechanism similar to RPCs
• RMI allows a Java program on one machine to invoke a a o s a a a p og a o o e ac e o o e amethod on a remote object