© 2026 schoolict.net (Ruwan Mangala Suraweera)
5.3 Process Management: States, PCB, Schedulers and Waiting Timeක්රියාවලි කළමනාකරණය: තත්ත්ව, PCB, කාර්ය සටහන්කරුවන් සහ රැඳී කාලය
Grade 12 A/L ICT · Lesson 512 ශ්රේණිය A/L ICT · පාඩම 5
In this videoමේ වීඩියෝවේ
- A process is a running program; a PCB stores its OS data.ක්රියාවලියක් ධාවනය වන වැඩසටහනකි; PCB එහි OS දත්ත තබයි.
- States include new, ready, running, waiting, terminated.තත්ත්ව: නව, සූදානම්, ධාවනය, රැඳී, අවසන්.
- Schedulers: long-term, short-term, medium-term.කාර්ය සටහන්කරුවන්: දීර්ඝ, කෙටි, මධ්ය.
- Waiting = turnaround − burst; throughput = jobs per time.රැඳී = පරිභ්රමණ − පිපිරුම්; ප්රතිදානතාව = කාලයකට රැකියා.
- FCFS and SJF examples show how to compute average waiting time.FCFS සහ SJF උදාහරණ සාමාන්ය රැඳී කාලය ගණනය කරන ආකාරය පෙන්වයි.
Notesසටහන්
Syllabus 5.3. A process is a program in execution. The OS creates processes, handles interrupts, tracks states, stores facts in a PCB, switches context, and uses schedulers. In this part you also meet turnaround, response, throughput and waiting time, with worked FCFS / SJF waiting-time calculations.විෂය නිර්දේශය 5.3. ක්රියාවලියක් යනු ක්රියාත්මක වන වැඩසටහනකි. OS ක්රියාවලි සාදයි, බාධක හසුරුවයි, තත්ත්ව ලුහුබඳියි, PCB එකක කරුණු තබයි, සන්දර්භය මාරු කරයි, කාර්ය සටහන්කරුවන් භාවිත කරයි. මෙම කොටසින් පරිභ්රමණ, ප්රතිචාර, ප්රතිදානතා සහ රැඳී කාල, සහ FCFS / SJF රැඳී-කාල ගණනය ද ඉගෙන ගනී.
1. Program vs process1. වැඩසටහන සහ ක්රියාවලිය
A program is passive (bytes on disk). A process is active: it has a program counter, registers, stack and an address space. Creating a process allocates a PCB, loads code, and sets the first state to ready (or new→ready).වැඩසටහන නිෂ්ක්රීයයි (තැටියේ බයිට්). ක්රියාවලිය සක්රියයි: PC, රෙජිස්තර, ස්ටැක් සහ ලිපින අවකාශයක් ඇත. ක්රියාවලියක් සෑදීමේදී PCB වෙන් කර කේතය පූරණය කරයි.
2. Interrupts2. බාධක
An interrupt is a signal that something needs the CPU’s attention (I/O finished, timer tick, error). The OS runs an interrupt handler, may save the current process’s state, then resumes or schedules another process.බාධකයක් යනු CPUගේ අවධානය අවශ්ය බවට සංඥාවකි. OS බාධක හසුරුවන්නෙකු ධාවනය කර, තත්ත්වය සුරකින අතර නැවත ආරම්භ කරයි හෝ වෙනත් ක්රියාවලියක් කාර්ය සටහන්ගත කරයි.
3. Process states and transitions3. ක්රියාවලි තත්ත්ව සහ සංක්රාන්ති
- New → being created.නව → සාදමින්.
- Ready → waiting for CPU.සූදානම් → CPU එකක් රැඳී.
- Running → on the CPU.ධාවනය → CPU මත.
- Waiting / blocked → waiting for I/O or an event.රැඳී / අවහිර → I/O හෝ සිදුවීමක් රැඳී.
- Terminated → finished or killed.අවසන් → අවසන් වී හෝ නවතා ඇත.
4. PCB and context switch4. PCB සහ සන්දර්භ මාරුව
The Process Control Block (PCB) holds the process ID, state, program counter, registers, scheduling info, memory maps and open files. A context switch saves one PCB’s volatile state and loads another’s so the CPU can run a different process.PCB එකේ ID, තත්ත්වය, PC, රෙජිස්තර, කාර්ය සටහන් තොරතුරු, මතක සිතියම් සහ විවෘත ගොනු තබයි. සන්දර්භ මාරුව එක් PCB තත්ත්වය සුරකින අතර අනෙක පූරණය කරයි.
5. Schedulers5. කාර්ය සටහන්කරුවන්
| Schedulerකාර්ය සටහන්කරු | Whenකවදාද | Jobකාර්යය |
|---|---|---|
| Long-termදීර්ඝ-කාලීන | Job admissionරැකියා ඇතුළත් කිරීම | Controls multi-programming degreeබහු-ක්රමලේඛන මට්ටම පාලනය කරයි |
| Short-term (CPU)කෙටි-කාලීන (CPU) | Very oftenඉතා නිතර | Picks who runs next on the CPUCPU මත ඊළඟට ධාවනය වන්නා තෝරයි |
| Medium-termමධ්ය-කාලීන | When memory is tightමතකය තද වූ විට | Swaps / suspends processesක්රියාවලි swap / අත්හිටුවයි |
Multi-programming keeps several processes in memory. Time-sharing gives interactive slices. Metrics: turnaround = finish − arrival; waiting = turnaround − burst; response ≈ first-run − arrival; throughput = jobs finished per unit time.බහු-ක්රමලේඛනය ක්රියාවලි කිහිපයක් මතකයේ තබයි. කාල බෙදාගැනීම අන්තර්ක්රියාකාරී කැබලි දෙයි. මිනුම්: පරිභ්රමණ = අවසන් − පැමිණීම; රැඳී = පරිභ්රමණ − පිපිරුම්; ප්රතිචාර ≈ පළමු ධාවනය − පැමිණීම; ප්රතිදානතාව = කාල ඒකකයකට අවසන් රැකියා.
Throughput = 20/10 = 2 jobs/s.ප්රතිදානතාව = 20/10 = තත්පරයට රැකියා 2.
6. Worked example – FCFS waiting times6. විසඳූ උදාහරණය – FCFS රැඳී කාල
FCFS (First-Come-First-Served) runs processes in arrival order with no preemption.FCFS පැමිණීමේ අනුපිළිවෙලින් ක්රියාවලි ධාවනය කරයි.
Waits = 0, 4, 6, 13. Average waiting time = 5.75 ms.රැඳී = 0, 4, 6, 13. සාමාන්ය රැඳී කාලය = 5.75 ms.
| Processක්රියාවලිය | Arrivalපැමිණීම | Burstපිපිරුම් | Startආරම්භය | Finishඅවසානය | Waitරැඳී |
|---|---|---|---|---|---|
| P1P1 | 00 | 55 | 00 | 55 | 00 |
| P2P2 | 11 | 33 | 55 | 88 | 44 |
| P3P3 | 22 | 88 | 88 | 1616 | 66 |
| P4P4 | 33 | 66 | 1616 | 2222 | 1313 |
7. Worked example – SJF (non-preemptive)7. විසඳූ උදාහරණය – SJF (පූර්ව-නොකළ)
SJF picks the ready job with the shortest burst next.SJF සූදානම් රැකියා අතරින් කෙටිම පිපිරුම් ඇති එක තෝරයි.
Order runs P1, then P3, then P2, then P4. Waits = 0, 6, 3, 7. Average = 4 ms.අනුපිළිවෙල P1, P3, P2, P4. රැඳී = 0, 6, 3, 7. සාමාන්ය = 4 ms.
| Processක්රියාවලිය | Arrivalපැමිණීම | Burstපිපිරුම් | Startආරම්භය | Waitරැඳී |
|---|---|---|---|---|
| P1P1 | 00 | 77 | 00 | 00 |
| P3P3 | 44 | 11 | 77 | 33 |
| P2P2 | 22 | 44 | 88 | 66 |
| P4P4 | 55 | 44 | 1212 | 77 |
Key Wordsප්රධාන පද
Sample Q&Aආදර්ශ ප්රශ්න සහ පිළිතුරු
1Distinguish a program and a process.වැඩසටහනක් සහ ක්රියාවලියක් වෙන්කර හඳුනාගන්න.
2What does a PCB store?PCB එකක තබා ඇත්තේ කුමක්ද?
3What is a context switch?සන්දර්භ මාරුවක් යනු කුමක්ද?
4Name the three scheduler types.කාර්ය සටහන්කරු වර්ග තුන නම් කරන්න.
5Define waiting time and turnaround time.රැඳී කාලය සහ පරිභ්රමණ කාලය අර්ථ දක්වන්න.
6In the FCFS example, what is the average waiting time?FCFS උදාහරණයේ සාමාන්ය රැඳී කාලය කුමක්ද?
MCQබහුවරණ ප්රශ්න
Choose the correct answer for each question.සෑම ප්රශ්නයකටම නිවැරදි පිළිතුර තෝරන්න.
1A process isක්රියාවලියක් යනු
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Active execution.සක්රිය ක්රියාත්මක වීම.
2PCB stands forPCB යනු
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
OS process record.OS ක්රියාවලි වාර්තාව.
3A process in the ready state isසූදානම් තත්ත්වයේ ක්රියාවලියක්
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Ready queue.සූදානම් පෝලිම.
4Context switchingසන්දර්භ මාරු කිරීම
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Switch processes on CPU.CPU මත ක්රියාවලි මාරු.
5The short-term schedulerකෙටි-කාලීන කාර්ය සටහන්කරු
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E
CPU scheduler.CPU කාර්ය සටහන්කරු.
6FCFS scheduling servesFCFS කාර්ය සටහන්ගත කිරීම සේවා කරන්නේ
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E
First come first served.පළමුව පැමිණි පළමුව.
7SJF picks the ready job withSJF තෝරන්නේ
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Shortest job first.කෙටිම රැකියාව පළමු.
8Waiting time equalsරැඳී කාලය සමාන වන්නේ
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Time in ready queue.සූදානම් පෝලිමේ කාලය.
9Throughput isප්රතිදානතාව යනු
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Jobs/time.රැකියා/කාලය.
10If 20 jobs finish in 10 s, throughput isරැකියා 20 ක් තත්පර 10 කින් අවසන් නම් ප්රතිදානතාව
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
20/10=2.20/10=2.
11In the lesson FCFS example, average waiting time isපාඩමේ FCFS උදාහරණයේ සාමාන්ය රැඳී කාලය
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
(0+4+6+13)/4.(0+4+6+13)/4.
12In the lesson SJF example, average waiting time isපාඩමේ SJF උදාහරණයේ සාමාන්ය රැඳී කාලය
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E
Computed SJF average.ගණනය කළ SJF සාමාන්යය.
13Which term means: “A program in execution with its own state”?“තමන්ගේ තත්ත්වය සහිත ක්රියාත්මක වන වැඩසටහනකි” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Process – A program in execution with its own state.ක්රියාවලිය – තමන්ගේ තත්ත්වය සහිත ක්රියාත්මක වන වැඩසටහනකි.
14Which term means: “Signal that needs CPU attention now”?“දැන් CPU අවධානය අවශ්ය සංඥාවකි” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Interrupt – Signal that needs CPU attention now.බාධකය – දැන් CPU අවධානය අවශ්ය සංඥාවකි.
15Which term means: “Process Control Block – OS record for a process”?“Process Control Block – ක්රියාවලියක OS වාර්තාව” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
PCB – Process Control Block – OS record for a process.PCB – Process Control Block – ක්රියාවලියක OS වාර්තාව.
16Which term means: “Saving one process state and loading another”?“එක් ක්රියාවලි තත්ත්වය සුරකින අතර අනෙක පූරණය කිරීම” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Context switch – Saving one process state and loading another.සන්දර්භ මාරුව – එක් ක්රියාවලි තත්ත්වය සුරකින අතර අනෙක පූරණය කිරීම.
17Which term means: “Waiting for the CPU”?“CPU එකක් රැඳී සිටී” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Ready state – Waiting for the CPU.සූදානම් තත්ත්වය – CPU එකක් රැඳී සිටී.
18Which term means: “Blocked for I/O or an event”?“I/O හෝ සිදුවීමක් සඳහා අවහිරයි” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Waiting state – Blocked for I/O or an event.රැඳී තත්ත්වය – I/O හෝ සිදුවීමක් සඳහා අවහිරයි.
19Which term means: “Admits jobs into the system”?“රැකියා පද්ධතියට ඇතුළත් කරයි” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Long-term scheduler – Admits jobs into the system.දීර්ඝ-කාලීන කාර්ය සටහන්කරු – රැකියා පද්ධතියට ඇතුළත් කරයි.
20Which term means: “Chooses the next process for the CPU”?“CPU සඳහා ඊළඟ ක්රියාවලිය තෝරයි” යන්නෙන් අදහස් වන පදය කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E
Short-term scheduler – Chooses the next process for the CPU.කෙටි-කාලීන කාර්ය සටහන්කරු – CPU සඳහා ඊළඟ ක්රියාවලිය තෝරයි.
MCQ answer keyMCQ පිළිතුරු
- B – Active execution.සක්රිය ක්රියාත්මක වීම.
- C – OS process record.OS ක්රියාවලි වාර්තාව.
- D – Ready queue.සූදානම් පෝලිම.
- B – Switch processes on CPU.CPU මත ක්රියාවලි මාරු.
- E – CPU scheduler.CPU කාර්ය සටහන්කරු.
- E – First come first served.පළමුව පැමිණි පළමුව.
- A – Shortest job first.කෙටිම රැකියාව පළමු.
- C – Time in ready queue.සූදානම් පෝලිමේ කාලය.
- A – Jobs/time.රැකියා/කාලය.
- B – 20/10=2.20/10=2.
- A – (0+4+6+13)/4.(0+4+6+13)/4.
- E – Computed SJF average.ගණනය කළ SJF සාමාන්යය.
- D – Process – A program in execution with its own state.ක්රියාවලිය – තමන්ගේ තත්ත්වය සහිත ක්රියාත්මක වන වැඩසටහනකි.
- D – Interrupt – Signal that needs CPU attention now.බාධකය – දැන් CPU අවධානය අවශ්ය සංඥාවකි.
- C – PCB – Process Control Block – OS record for a process.PCB – Process Control Block – ක්රියාවලියක OS වාර්තාව.
- A – Context switch – Saving one process state and loading another.සන්දර්භ මාරුව – එක් ක්රියාවලි තත්ත්වය සුරකින අතර අනෙක පූරණය කිරීම.
- C – Ready state – Waiting for the CPU.සූදානම් තත්ත්වය – CPU එකක් රැඳී සිටී.
- D – Waiting state – Blocked for I/O or an event.රැඳී තත්ත්වය – I/O හෝ සිදුවීමක් සඳහා අවහිරයි.
- B – Long-term scheduler – Admits jobs into the system.දීර්ඝ-කාලීන කාර්ය සටහන්කරු – රැකියා පද්ධතියට ඇතුළත් කරයි.
- E – Short-term scheduler – Chooses the next process for the CPU.කෙටි-කාලීන කාර්ය සටහන්කරු – CPU සඳහා ඊළඟ ක්රියාවලිය තෝරයි.
Structured Questionsව්යුහගත ප්රශ්න
1Distinguish program and process; list three PCB contents.වැඩසටහන සහ ක්රියාවලිය වෙන්කර PCB අන්තර්ගත තුනක් ලැයිස්තුගත කරන්න. (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
2Describe ready, running and waiting states.සූදානම්, ධාවනය සහ රැඳී තත්ත්ව විස්තර කරන්න. (3 marksලකුණු 3)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
3Compare long-term and short-term schedulers.දීර්ඝ-කාලීන සහ කෙටි-කාලීන කාර්ය සටහන්කරුවන් සංසන්දනය කරන්න. (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
4For the FCFS data in the notes, show waits and the average.සටහන්වල FCFS දත්ත සඳහා රැඳී කාල සහ සාමාන්යය පෙන්වන්න. (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
5Define waiting, turnaround and throughput; give the 20-jobs-in-10-s throughput.රැඳී, පරිභ්රමණ සහ ප්රතිදානතාව අර්ථ දක්වා රැකියා 20/තත්පර 10 ප්රතිදානතාව දෙන්න. (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
🎮 Game🎮 ක්රීඩා
Summary & Downloadsසාරාංශය සහ බාගත කිරීම්
Key pointsප්රධාන කරුණු
- A process is a running program; a PCB stores its OS data.ක්රියාවලියක් ධාවනය වන වැඩසටහනකි; PCB එහි OS දත්ත තබයි.
- States include new, ready, running, waiting, terminated.තත්ත්ව: නව, සූදානම්, ධාවනය, රැඳී, අවසන්.
- Schedulers: long-term, short-term, medium-term.කාර්ය සටහන්කරුවන්: දීර්ඝ, කෙටි, මධ්ය.
- Waiting = turnaround − burst; throughput = jobs per time.රැඳී = පරිභ්රමණ − පිපිරුම්; ප්රතිදානතාව = කාලයකට රැකියා.
- FCFS and SJF examples show how to compute average waiting time.FCFS සහ SJF උදාහරණ සාමාන්ය රැඳී කාලය ගණනය කරන ආකාරය පෙන්වයි.
