Contents
Chapter 3 · SoftwarePractice

LEARN WITH HARU

Video Lesson တွေက Haru အတန်းသားတွေအတွက်ပါ

Haru ရဲ့ ITPEC FE Full Course မှာ ယခု သင်ခန်းစာတွေကို တစ်ခုချင်း တစ်ကြောင်းချင်း အသေးစိတ်ရှင််ရှင်းပြထားပါတယ်

အခြေခံ မရှိတဲ့ ကျောင်းသားများစွာဟာလည်း ဒီ Course နဲ့ ပဲ အောင်မြင်ကုန်ကြပါပြီ

အတန်းမအပ်သေးပဲ Haru ဆီမှာ အစမ်းသင်ကြည့်ချင်ပါသလား?

သင်တန်းသားတွေရဲ့ စကားသံများ

သင်တန်းသားတွေရဲ့ စကားသံများ

Highlighted text? Practice this concept. Highlighted passages and figures open related questions.

Practice related questions (9)Progress & bookmarks

Current section

2-2-2 Task Management

p. 199

Practice this section 9 linked exam questions with default filters

Progress

Not marked complete

Related questions in this lesson 10

Task states and CPU allocation3Round-robin scheduling2Preemption and task priority scheduling4First-come first-served scheduling1
Progress and bookmarks

p. 199

2-2-2 Task Management

Task management is a function that manages the execution of tasks, which are the units of work from the perspective of a machine (i.e., computer). Some OSs refer to a task as a process, so this is sometimes called process management. A task becomes executable when the CPU is allocated to it. Therefore, the flow (i.e., procedure) of task execution with task management means a procedure for allocation of the CPU to tasks without waste. The management (i.e., execution) of multiple tasks in parallel is called multitasking. Multiprogramming, in which multiple processes appear to a user to be running simultaneously, is implemented with multitasking. The general flow of task execution with task management can be summarized with a state transition diagram (i.e.., a diagram displaying the state of a system that is changed according to time and events) as shown below.

Task state transitions: generation to ready; ready to running; running back to ready, waiting or termination; waiting back to ready. Original numbered explanations continue on the next page. Source text: [State transition diagram of tasks] (1) Tasks are generated from a job (i.e., job step) that is to be executed. Resources other than the CPU are allocated to the task, and when the CPU is allocated, the task enters the executable ready state. (2) When the CPU is allocated to the task, the task changes to the running state. (3) If a task with a higher priority than the currently running task changes to the ready state or the running task uses up the CPU time (i.e., time quantum) allocated to it, the running task is temporarily halted and returned to the ready state and has to wait for CPU allocation. (4) If the running task requests a resource (for example, execution of an input/output instruction), the task is halted and enters the waiting state until the requested resource is available.
p. 199 · Enlarge
Task states and CPU allocation · 3 practice questions

p. 200

Original textbook callout or table. Source text: (5) As soon as the requested resource for the waiting task is available, the task changes to the ready state. (6) When the task is completed after the CPU is allocated several times, it is terminated.
p. 200 · Enlarge

In order to halt a task that is being executed and run the management program, an interrupt occurs.

Original concurrent-task example. A has CPU 30, I/O 30, CPU 20 milliseconds; B has CPU 20, I/O 20, CPU 30. A has higher priority. CPU timeline: A 0-30, B 30-50, idle 50-60, A 60-80, B 80-110. I/O: A 30-60, B 60-80. Original numbered explanation continues on the next page. Source text: Example: If the two tasks A and B are executed concurrently, how many milliseconds does it take before both tasks are completed? Here, task A has the higher priority. <Task scheduling results> (1) Tasks A and B are generated and enter the ready state. (2) The CPU is allocated to task A with the higher priority, and task A changes to the running state. (3) When CPU processing for task A is completed and task A requests I/O processing, an SVC interrupt occurs and task A enters the waiting state. I/O is not being used, so I/O processing for task A starts. (4) The CPU is allocated to task B, and task B changes to the running state. (5) When CPU processing for task B is completed and task B requests I/O processing, an SVC interrupt occurs and task B enters the waiting state. Task A is using I/O, so task B must wait for I/O to become available. (6) When I/O processing for task A is completed, an input/output (completion) interrupt occurs and task A changes to the ready state. As a result, I/O becomes available, and then I/O processing for task B starts. (7) The CPU is allocated to task A, and task A changes to the running state. (8) When CPU processing for task A finishes, task A is completed and is thus terminated.
p. 200 · Enlarge

p. 201

Original textbook callout or table. Source text: (9) When I/O processing for task B is completed, an input/output (completion) interrupt occurs and task B changes to the ready state. (10) The CPU is allocated to task B, and task B changes to the running state. (11) When CPU processing for task B finishes, task B is completed and is thus terminated.
p. 201 · Enlarge

Task management uses functions (1) to (3) below in order to implement this procedure for task execution (i.e., multitasking).

(1) Dispatcher

A dispatcher is a task management program that selects (dispatches) a task to be executed from multiple tasks in the ready state. The criteria for selecting a task are decided depending on task scheduling.

Original textbook callout or table. Source text: [Task scheduling] • Preemptive This is a method where a task being executed is temporarily halted under the control of the OS (or a preemption occurs). • Priority scheduling This is a method where the CPU is allocated to the task with the highest priority first according to the priority assigned to each task. It includes static priority scheduling in which the assigned priority cannot be changed, and dynamic priority scheduling which enables the priority to be raised (aging) when a process with a low priority is waiting for a long time without being executed (starvation). Methods, such as priority scheduling, in which the occurrence of an event is used as a trigger are called event-driven methods. • Shortest processing time first This is a method that assigns a high priority to tasks that have a short expected processing time and processes them earlier. This method increases the potential for tasks with a long expected processing time to wait continuously for CPU allocation. • Round robin This is a method that manages ready-state tasks in a queue in order of arrival, and at a given time interval (i.e., time quantum) allocates the CPU to the task at the head of the queue. Tasks that are not finished but have used up the allotted time are sent to the back of the queue. Methods that allocate a very small set amount of time to a task,
p. 201 · Enlarge
Preemption and task priority scheduling · 4 practice questionsRound-robin scheduling · 2 practice questions

p. 202

Original textbook callout or table. Source text: such as round robin, are called time slice methods. • Non-preemptive This is a method where a task that is being executed is not halted under the control of the OS. • First-come first-served This is a method that manages ready-state tasks in a queue in order of arrival. When a task that is being executed finishes, the CPU is allocated to the task at the head of the queue.
p. 202 · Enlarge
First-come first-served scheduling · 1 practice questions

(2) Semaphore

Semaphore is used in mutual control (i.e., exclusive control), which synchronizes tasks and manages shared resources, when resources are allocated to a task. In actual terms, it performs control between tasks with the P operation when a resource is requested and the V operation when a resource is released.

Original binary-semaphore P/V example, including the full explanatory box. Task A secures the resource with P, taking S from 1 to 0. Task B requests it and waits. A releases with V; allocation to B follows. B later releases with V, restoring S=1. Arrows distinguish requests, waiting, allocation and releases. Source text: [P operation / V operation] These are operations that secure and release resources on the basis of the semaphore variable of each resource. When semaphore variables can only be either 0 or 1 because only a single resource can be allocated, it is known as binary semaphore. • P operation: This is an operation that is performed when a resource is requested. If the semaphore variable is “1” or more, the resource is secured and “1” is subtracted from the semaphore variable. If the semaphore variable is “0”, the waiting state is entered until the resource is released. • V operation: This is an operation that is performed when a resource is to be released. If a task is waiting for the same resource, the resource is allocated and “1” is added to the semaphore variable.
p. 202 · Enlarge

p. 203

(2) Threads

A thread is a subdivision of a task, and can only be allocated CPU resources. It is also called a lightweight process (lightweight task). For memory and other resources, it uses the resources that are allocated before subdivision. Not every OS has a thread function.

Original chapter exercises

Original chapter exercises →

New FE Textbook Vol.1 · IT Fundamentals · First Edition, April 2015