Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

PROCESS STATES AND MEMORY MANAGER

LO 1 : Investigating Process States and State Transitions


Action to take Resultant State Success Fail

(Y or N) (Y or N)

1. Drag process to Eror : ilegal state


the waiting queue transition N Y
(i.e. put in waiting
state)

2. Drag process to Eror : ilegal state


the Process Bin transition N Y
(i.e. terminate it)

3. Drag process to Sukses


the CPU 0 box (i.e. Y N
run it)

4. Drag process to Sukses


the waiting queue Y N

5. Drag process to Eror : ilegal state


the CPU 0 box transition N Y

6. Drag process to Eror : ilegal state


the Process Bin transition N Y

7. Drag process to Kembali ke CPU 0


the Ready Queue N Y
(i.e. put it in ready
state)

8. Click on the Eror : ilegal state


RESUME button
in OS Control tab transition N Y

9. Drag process to Kembali ke CPU 0


the ready queue N Y

10. Click on the Eror : ilegal state


RESUME button transition N Y
in OS Control tab

11. Drag process to Sukses


Process Bin Y N

Next, based on the results above, fill in only the legal state changes in the table
below :

From State To State

Ready State Running State

Running State Waiting State

Running State Process Bin

Ready

Waiting Running
LO :  Investigating Process States – Waiting Queue and Events
State

1. Running

2. Running

3. Running

4. Waiting

5.Running

6. Ready

INVESTIGATING THREADS
LO1 . Write a source code that creates threads.
Briefly explain what the above code is doing: Menciptakan dua sub thread dimana
thread1 adalah untuk menampilkan output dari writeln dan untuk thread2 untuk
memanggil sub thread1 setelah menjalankan thread1 dan itu akan menampilkan output
di thread2 dan kodenya adalah pernyataan loop yang memanggil thread2 dan
menampilkan keluaran dan inmain.

List the order in which you expect the text to be displayed by the “writeln” statements:
di thread1 dan thread2
LO2. Use the simulator to compile and run the code.
LO3. Display the list of processes/threads and the tree of processes
showing the parent/child process relationship.
a) Compile the above source and load the generated code in memory.

b) Make the console window visible by clicking on the INPUT/OUTPUT…


button. Also make sure the console window stays on top by checking the Stay on
top check box.

c) Now, go to the OS simulator window (use the OS… button in the CPU
simulator window) and create a single process of program ThreadTest1 in the
program list view. For this use the CREATE NEW PROCESS button.

d) Make sure the scheduling policy selected is Round Robin and that the
simulation speed is set at maximum.

e) Hit the START button and at the same time observe the displays on the console
window.
Briefly explain your observations: Program menunjukkan "in main" terlebih dahulu

kemudian tampilkan output dari thread1 dan thread2.

f)How
Now,many
clickprocesses are created?
on the Views tab and3click on the VIEW PROCESS LIST… button.
Observe
Identify,the
by contents of theis window
name, which a processnow
anddisplaying.
which is a thread: Theadtest1, P1t2, P1t2t3

Briefly explain your observations: Menampilkan proses PPID,CPUT,STA,MEM,CPUE


dan ETMS dan proses tampilan sedang berjalan.

What do you think the PPID field signifies? Proses awal mungkin akan terbagi
menjadi proses proses lainya yang masing-masing mempunyai PID yang unik dan
berbagi PPID yang sama

Is there equivalent information in MS Windows? Ada yang setara dengan TM dimana ia


memiliki Nama, PID, status, UAC virtualisasi, memori dan nama pengguna.
g) In the Process List window hit the PROCESS TREE… button. Observe the
contents of the window now displaying.
Briefly explain your observations: Menampilkan proses root dimana itu menunjukan
proses utama dan turunanya.

How are the parent/child process relationships represented? Menunjukan bahwa


threadtest1 berada di atas dan P1T2 berada di bawahnya sedangkan P1T2T3 berada di
bawah P1T2

Identify the parent and the children processes: Threadtest1 adalah proses utama
sedangkan P1T2 dan P1T2T2 adalah turunan dari P1T2

LO4. Demonstrate that threads share their parent’s data areas


Briefly explain what effect the modifications will have: s1 dan s2 memiliki 6 variabel
dan proses utama akan menunggu turunanya sebelum diberhentikan.

a) Compile the above source and load the generated code in memory.

b) Click on the SYMBOL TABLE… button in the compiler window. In the


displayed window, observe the information on variables s1 and s2.

Make a note below of the data memory addresses for variables s1 and s2:
c)s1Make the s2
- 0006, console
- 0014window visible by clicking on the INPUT/OUTPUT… button.
Also make sure the console window stays on top by checking the Stay on top
check box.

d) Now, go to the OS simulator window and create a single process of program


ThreadTest2 in the program list view. For this use the CREATE NEW PROCESS
button.
e) Make sure the scheduling policy selected is Round Robin and that the simulation
speed is set at maximum.

f) Hit the START button and after all the displays on the console window are done
use the SUSPEND button to temporarily suspend the processes. Identify and select
the grandparent process.

g) Now, click on the SHOW MEMORY… button. This action will display the data
area of the selected process. Observe the contents of the memory areas of variables
s1 and s2 (use the address values you noted down in (b) above).

h) Display the memory areas of the child processes and again observe the contents
of the memory areas of variables s1 and s2 (note that each string variable’s data
starts with the first byte set to 03).

Briefly explain what your general observations are and suggest what the significance of
your observations is: Menunggu proses turunan sebelum itu berakhir dan memori acara
itu menampilkan setiap baris proses masing-masing diwakili dengan 8 byte data dan
alamat data memori yang sebelumnya muncul di memori data dengan string hello1 dan
hello2

LO5. Modify the source code to create a version not using threads to
be able to compare the two versions.
a) Modify the source code for ThreadTes1 by removing the two instances of “as
thread” from the two subroutine declarations. You may wish to call this modified
source code ThreadTest3.

b) Compile the code and load in memory.

c) Create a process of it and run in the OS simulator.

d) Observe the display in the console window

Briefly describe what you observe and explain how and why this differs from the results
of the previous processes: Menampilkan output yang diharapkan tapi di threadtest3
hanya menampilkan inthread1.
LO6. Simulate a multi-threaded server program
a. Compile the above source, load the generated code in memory and run it.

b. Make a note below of what you observe on the OS simulator window:

Saat mengamati program, proses yang dibuat dalam proses siap dan UJI SERVER
Proses akan pergi ke proses menunggu. P1T0 juga dibuat dan akan tetap berada di
c. On the console window type 1 four times one after the other and observe the
proses.
displays on the console.

d. When all the threads finish then make a note of the displays on the console.

Servertest menyelesaikan proses sementara konsol menampilkan started service dan


empat finished service

e. Type q on the console to stop the server program.

f. Now, modify the above code by removing the “as thread” construct from the
subroutine ServiceThread.

g. Compile the above source, load the generated code in memory and run it.

h. On the console window type 1 four times one after the other and observe the
displays on the console.

i. When all the threads finish then make a note of the displays on the console.

j.
Menampilkan started service dan finished service

You might also like