Linux Task Scheduling

Size: px
Start display at page:

Download "Linux Task Scheduling"

Transcription

1 Linux Task Scheduling Hyunmin Yoon

2 2 This document is based-on linux version (released at ) 2

3 3 Task Scheduling COMPLETELY FAIR SCHEDULING 3

4 4 Completely Fair Scheduler (CFS) CFS is based on a simple concept The goal is to achieve an ideal multitasking system Provide each task CPU time proportional to its weight CPU time Weight of task Total weight Total CPU time Preemption point Task #1 Task #2 Total CPU time Time Weight of task #1 = 3 Weight of task #2 = 2 4

5 5 Virtual Runtime Virtual Runtime (vruntime) Approximate the "ideal multitasking" that CFS is modeling To account for how long a process has run how much longer it ought to run VVVV ττ, tt = WW 00 WW ττ PPPP tt WW 00 : the weight of nice value 0 WW(tt): the weight of the task PPPP(tt): actual runtime of the task in time interval [0, t] Scheduler chooses a task with the smallest virtual runtime 5

6 6 Example VVVV ττ, tt = WW 00 WW ττ PPPP tt PPPP tt = 55 WW ττ 11, tt = 33, WW ττ 22, tt = 22 WW 00 = CC Task #1 Task #2 5 seconds Time VVVV ττ 11, tt VVVV ττ 22, tt VVVV ττ 11, tt VVVV ττ 22, tt (1) 1 3 CC 0 (4) 2 CC CC 3 (2) 1 Time (5) 4 Time (3) 2 Time 1 3 CC 1 2 CC 5 Time CC CC 3 Time 2 3 CC 1 2 CC 6

7 7 Task Weight include/linux/sched.c struct load_weight unsigned long weight, inv_weight; ; kernel/sched.c static const int prio_to_weight[40] = /* -20 */ 88761, 71755, 56483, 46273, 36291, /* -15 */ 29154, 23254, 18705, 14949, 11916, /* -10 */ 9548, 7620, 6100, 4904, 3906, /* -5 */ 3121, 2501, 1991, 1586, 1277, /* 0 */ 1024, 820, 655, 526, 423, /* 5 */ 335, 272, 215, 172, 137, /* 10 */ 110, 87, 70, 56, 45, /* 15 */ 36, 29, 23, 18, 15, ; /* Inverse (2^32/x) values of the prio_to_weight[] array, precalculated. */ static const u32 prio_to_wmult[40] = /* -20 */ 48388, 59856, 76040, 92818, , /* -15 */ , , , , , /* -10 */ , , , , , /* -5 */ , , , , , /* 0 */ , , , , , /* 5 */ , , , , , /* 10 */ , , , , , /* 15 */ , , , , , ; 7

8 8 Update Virtual Runtime <kernel/sched/fair.c> /* * Update the current task's runtime statistics. */ static void update_curr(struct cfs_rq *cfs_rq) struct sched_entity *curr = cfs_rq->curr; u64 now = rq_clock_task(rq_of(cfs_rq)); u64 delta_exec; delta_exec = now - curr->exec_start; curr->sum_exec_runtime += delta_exec; curr->vruntime += calc_delta_fair(delta_exec, curr); update_min_vruntime(cfs_rq); /* * delta /= w */ static inline u64 calc_delta_fair(u64 delta, struct sched_entity *se) if (unlikely(se->load.weight!= NICE_0_LOAD)) delta = calc_delta(delta, NICE_0_LOAD, &se->load); Calculate the execution time of the current task Update virtual runtime VVVV ττ, tt = WW 00 WW ττ PPPP tt return delta; 8

9 9 Virtual Runtime Calculation <kernel/sched/fair.c> calc_delta(delta, NICE_0_LOAD, &se->load); static u64 calc_delta(u64 delta_exec, unsigned long weight, struct load_weight *lw) u64 fact = scale_load_down(weight); #define WMULT_CONST int shift = WMULT_SHIFT; #define WMULT_SHIFT 32 update_inv_weight(lw); NNNNNNNN_00_LLLLLLLL WWWWWWWWWW_CCCCCCCCCC wwwwwwwwwwww if (unlikely(fact >> 32)) while (fact >> 32) fact >>= 1; shift--; /* hint to use a 32x32->64 mul */ fact = (u64)(u32)fact * lw->inv_weight; while (fact >> 32) fact >>= 1; shift--; (~0U) static void update_inv_weight(struct load_weight *lw) unsigned long w; if (likely(lw->inv_weight)) return; w = scale_load_down(lw->weight); VVVV ττ, tt = WW 00 WW ττ PPPP tt inv_weight = 0 if se is member of a group if (BITS_PER_LONG > 32 && unlikely(w >= WMULT_CONST)) lw->inv_weight = 1; else if (unlikely(!w)) lw->inv_weight = WMULT_CONST; else lw->inv_weight = WMULT_CONST / w; return mul_u64_u32_shr(delta_exec, fact, shift); dddddddddd NNNNNNNN_00_LLLLLLLL wwwwwwwwwwww static inline u64 mul_u64_u32_shr(u64 a, u32 mul, unsigned int shift) return (u64)(((unsigned int128)a * mul) >> shift); 9

10 10 CFS Algorithm: Red Black Tree CFS maintains a time-ordered red black tree where all runnable tasks are sorted by virtual runtime No path in the tree will ever be more than twice as long as any other (self-balancing) Operations on the tree occur in O(log n) time 10

11 11 Overview of Scheduling Flow On each scheduling tick, CFS 1. Updates the virtual runtime of the currently running task 2. Checks between virtual runtime and time slice If vvvvvvvvvvvvvv rrrrrrrrrrrrrr (tttttttt ssssssssss), then TIF_NEED_RESCHED flag is set (thread information flag) 3. Checks TIF_NEED_RESCHED flag If set, schedules the task with the smallest virtual runtime in the run queue Enqueue the currently running task into the RB tree Dequeue the task at the left-most node in the RB tree 11

12 12 Timeslice Timeslice is the time a task runs before it is preempted It gives each runnable task a slice of the CPU s time The length of timeslice of a task is proportional to its weight TTSS ττ = WW ττ WW tt 12

13 13 Time Slice Calculation <kernel/sched/fair.c> /* * We calculate the wall-time slice from the period by taking a part * proportional to the weight. * * s = p*p[w/rw] */ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) u64 slice = sched_period(cfs_rq->nr_running +!se->on_rq); for_each_sched_entity(se) struct load_weight *load; struct load_weight lw; return slice; TTSS ττ = WW ττ WW tt cfs_rq = cfs_rq_of(se); load = &cfs_rq->load; if (unlikely(!se->on_rq)) lw = cfs_rq->load; update_load_add(&lw, se->load.weight); load = &lw; slice = calc_delta(slice, se->load.weight, load); ssssssssss wwwwwwwwwwww wwwwwwwwwwww /* * Minimal preemption granularity for CPU-bound tasks: * (default: 0.75 msec * (1 + ilog(ncpus)), units: nanoseconds) */ unsigned int sysctl_sched_min_granularity = ULL; static unsigned int sched_nr_latency = 8; static u64 sched_period(unsigned long nr_running) if (unlikely(nr_running > sched_nr_latency)) return nr_running * sysctl_sched_min_granularity; else return sysctl_sched_latency; /* * Targeted preemption latency for CPU-bound tasks: * (default: 6ms * (1 + ilog(ncpus)), units: nanoseconds) */ unsigned int sysctl_sched_latency = ULL; 13

14 14 Scheduling Process 1. Timer interrupt 2. IRQ handler 2-1. Setting NEED_RESCHED flag 2-2. Raising softirq for load balancing 3. Return from interrupt : 3-1. Scheduling (if the flag is set) 14

15 15 Setting TIF_NEED_RESCHED Flag 15

16 16 Scheduler Tick Handler <kernel/sched/core.c> void scheduler_tick(void) int cpu = smp_processor_id(); struct rq *rq = cpu_rq(cpu); struct task_struct *curr = rq->curr; sched_clock_tick(); raw_spin_lock(&rq->lock); update_rq_clock(rq); curr->sched_class->task_tick(rq, curr, 0); update_cpu_load_active(rq); calc_global_load_tick(rq); raw_spin_unlock(&rq->lock); Setting the flag for scheduling perf_event_task_tick(); #ifdef CONFIG_SMP rq->idle_balance = idle_cpu(cpu); trigger_load_balance(rq); #endif rq_last_tick_reset(rq); Raising softirq for load balancing 16

17 17 Tick Handler of Scheduling Class <kernel/sched/fair.c> /* * scheduler tick hitting a task of our scheduling class: */ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued) struct cfs_rq *cfs_rq; struct sched_entity *se = &curr->se; for_each_sched_entity(se) cfs_rq = cfs_rq_of(se); entity_tick(cfs_rq, se, queued); if (static_branch_unlikely(&sched_numa_balancing)) task_tick_numa(rq, curr); For group scheduling static void entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued) /* * Update run-time statistics of the 'current'. */ update_curr(cfs_rq); /* * Ensure that runnable average is periodically updated. */ update_load_avg(cfs_rq, curr, UPDATE_TG); update_cfs_group(curr); For load balancing For group scheduling if (cfs_rq->nr_running > 1) check_preempt_tick(cfs_rq, curr); 17

18 18 Check The Necessity of Preemption <kernel/sched/fair.c> static void check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr) unsigned long ideal_runtime, delta_exec; struct sched_entity *se; s64 delta; TTSS cccccccc = WW cccccccc WW tt ideal_runtime = sched_slice(cfs_rq, curr); delta_exec = curr->sum_exec_runtime - curr->prev_sum_exec_runtime; if (delta_exec > ideal_runtime) resched_curr(rq_of(cfs_rq)); clear_buddies(cfs_rq, curr); return; set TIF_NEED_RESCHED flag Get an entity with minimum vruntime from RB tree /* * Ensure that a task that missed wakeup preemption by a * narrow margin doesn't have to wait for a full slice. * This also mitigates buddy induced latencies under load. */ if (delta_exec < sysctl_sched_min_granularity) return; se = pick_first_entity(cfs_rq); delta = curr->vruntime - se->vruntime; if (delta < 0) return; if (delta > ideal_runtime) resched_curr(rq_of(cfs_rq)); /* * Minimal preemption granularity for CPU-bound tasks: * (default: 0.75 msec * (1 + ilog(ncpus)), units: nanoseconds) */ unsigned int sysctl_sched_min_granularity = ULL; Scheduler guarantees that a task should run during minimum time slice Current task has still minimum vruntime in RB tree If vvvvvvvvvvvvvvee cccccccc > vvvvvvvvvvvvvvee llllllllllllllll + TTSS cccccccc then set TIF_NEED_RESCHED flag 18

19 19 Calling Scheduler <arch/arm/kernel/entry-common.s> slow_work_pending: mov mov bl ENTRY(ret_to_user_from_irq) ldr tst bne r0, 'regs' r2, 'syscall' do_work_pending r1, [tsk, #TI_FLAGS] r1, #_TIF_WORK_MASK slow_work_pending <arch/arm/kernel/signal.c> Return to user from interrupt request asmlinkage int do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall) trace_hardirqs_off(); do if (likely(thread_flags & _TIF_NEED_RESCHED)) schedule(); else 19

20 20 CFS put_prev_entity() set_next_entity() 20

21 21 Scheduling Function <kernel/sched/core.c> asmlinkage visible void sched schedule(void) struct task_struct *tsk = current; sched_submit_work(tsk); do preempt_disable(); schedule(false); sched_preempt_enable_no_resched(); while (need_resched()); EXPORT_SYMBOL(schedule); Scheduling <include/linux/sched.h> static always_inline bool need_resched(void) return unlikely(tif_need_resched()); <include/linux/thread_info.h> #define tif_need_resched() test_thread_flag(tif_need_resched) 21

22 22 schedule() <kernel/sched/core.c> static void sched notrace schedule(bool preempt) struct task_struct *prev, *next; unsigned long *switch_count; struct rq *rq; int cpu; cpu = smp_processor_id(); rq = cpu_rq(cpu); prev = rq->curr; next = pick_next_task(rq, prev); clear_tsk_need_resched(prev); clear_preempt_need_resched(); Current task is set as previous task Dequeue next task & enqueue previous task if (likely(prev!= next)) rq->nr_switches++; rq->curr = next; ++*switch_count; trace_sched_switch(preempt, prev, next); else /* Also unlocks the rq: */ rq = context_switch(rq, prev, next, &rf); rq->clock_update_flags &= ~(RQCF_ACT_SKIP RQCF_REQ_SKIP); rq_unlock_irq(rq, &rf); balance_callback(rq); 22

23 23 Picking Next Task <sched/kernel/core.c> static inline struct task_struct *pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) const struct sched_class *class = &fair_sched_class; struct task_struct *p; if (likely(prev->sched_class == class && rq->nr_running == rq->cfs.h_nr_running)) p = fair_sched_class.pick_next_task(rq, prev, rf); if (unlikely(p == RETRY_TASK)) goto again; Count all task entities (they are not group entities) Count all entities of CFS runqueue (It includes group entities) Pick up next task for scheduling If CPU has only CFS tasks and it doesn t have any group /* assumes fair_sched_class->next == idle_sched_class */ if (unlikely(!p)) p = idle_sched_class.pick_next_task(rq, prev, rf); return p; again: From all of classes for_each_class(class) p = class->pick_next_task(rq, prev, rf); if (p) if (unlikely(p == RETRY_TASK)) goto again; return p; BUG(); /* the idle class will always have a runnable task */ 23

24 24 Picking Next Task (CFS) <kernel/sched/fair.c> static struct task_struct *pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) struct cfs_rq *cfs_rq = &rq->cfs; struct sched_entity *se; struct task_struct *p; int new_tasks; again: #ifdef CONFIG_FAIR_GROUP_SCHED if (!cfs_rq->nr_running) goto idle; if (prev->sched_class!= &fair_sched_class) goto simple; Skip codes for CFS group scheduling simple: cfs_rq = &rq->cfs; #endif if (!cfs_rq->nr_running) goto idle; put_prev_task(rq, prev); Put previous task to its class (some class enqueues the task) do while (cfs_rq); se = pick_next_entity(cfs_rq, NULL); set_next_entity(cfs_rq, se); cfs_rq = group_cfs_rq(se); Find next entity for scheduling For group scheduling p = task_of(se); if (hrtick_enabled(rq)) hrtick_start_fair(rq, p); return p; Set high-resolution timer for setting time slice (It allows for the task to check preemption point before 1/HZ seconds) Skip codes for idle 24

25 25 put_prev_entity <kernel/sched/fair.c> static void put_prev_entity(struct cfs_rq *cfs_rq, struct sched_entity *prev) /* * If still on the runqueue then deactivate_task() * was not called and update_curr() has to be done: */ if (prev->on_rq) update_curr(cfs_rq); if (prev->on_rq) update_stats_wait_start(cfs_rq, prev); /* Put 'current' back into the tree. */ enqueue_entity(cfs_rq, prev); cfs_rq->curr = NULL; /* in!on_rq case, update occurred at dequeue */ update_load_avg(prev, 0); Find the right place to be located static void enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) struct rb_node **link = &cfs_rq->tasks_timeline.rb_node; struct rb_node *parent = NULL; struct sched_entity *entry; int leftmost = 1; while (*link) parent = *link; entry = rb_entry(parent, struct sched_entity, run_node); if (entity_before(se, entry)) link = &parent->rb_left; else link = &parent->rb_right; leftmost = 0; Insert the task rb_link_node(&se->run_node, parent, link); rb_insert_color_cached(&se->run_node, &cfs_rq->tasks_timeline, leftmost); Update rb_leftmost if the inserted task is located on the leftmost node if (newleft) *leftmost = node; 25

26 26 pick_next_entity <kernel/sched/fair.c> /* * Pick the next process, keeping these things in mind, in this order: * 1) keep things fair between processes/task groups * 2) pick the "next" process, since someone really wants that to run * 3) pick the "last" process, for cache locality * 4) do not run the "skip" process, if something else is available */ static struct sched_entity *pick_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *curr) struct sched_entity *left = pick_first_entity(cfs_rq); struct sched_entity *se; /* * If curr is set we have to see if its left of the leftmost entity * still in the tree, provided there was anything in the tree at all. */ if (!left (curr && entity_before(curr, left))) left = curr; se = left; /* ideally we run the leftmost entity */ Skip codes for (2)~(4) struct sched_entity * pick_first_entity(struct cfs_rq *cfs_rq) struct rb_node *left = cfs_rq->rb_leftmost; return se; if (!left) return NULL; return rb_entry(left, struct sched_entity, run_node); Pick an leftmost entity on the CFS RB tree 26

27 27 set_next_entity <kernel/sched/fair.c> static void set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) /* 'current' is not kept within the tree. */ if (se->on_rq) update_stats_wait_end(cfs_rq, se); dequeue_entity(cfs_rq, se); update_load_avg(se, 1); update_stats_curr_start(cfs_rq, se); cfs_rq->curr = se; se->prev_sum_exec_runtime = se->sum_exec_runtime; Update the rb_leftmost if the task is the leftmost node static void dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) if (cfs_rq->rb_leftmost == &se->run_node) struct rb_node *next_node; next_node = rb_next(&se->run_node); cfs_rq->rb_leftmost = next_node; Remove the task from the RB tree rb_erase(&se->run_node, &cfs_rq->tasks_timeline); 4.6 codes for easy to understand 27

28 28 Task Attachment Functions enqueue_entity enqueue_entity enqueue_task (call an enqueue function of corresponding class ) Unthrottle activate_task attach_task Load balancing Swap (cross migration between CPUs) Wake up Fork Move between groups Move between classes Move between CPUs Change NICE Change CPU list that task allows to run Put current task back into the tree 28

29 29 Quiz In the following situations, analyze how CFS schedules tasks virtual runtime = 100 running state State of a task virtual runtime =? running state time 10 minutes fork sleep wake up time Running time of tasks 29

30 30 Stride Scheduler HOMEWORK 30

31 31 Complete Stride Scheduler Complete the following functions 1. enqueue_task_stride() 2. dequeue_task_stride() 3. set_curr_task_stride() 4. pick_next_task_stride() 1. put_prev_task_stride() 31

32 32 Restrictions Scheduler has 1,000 tickets <my_stride> = 1,000 <my_tickets> (tickets) < 1,000 Initial pass <initial_pass> = <my_stride> Competition handling If current process has lowest pass, then it is executed continuously ex) If current = P1, P1.pass = 100, P2.pass = 100, then P1 is executed continuously 32

33 33 Result stride_app$./stride_app Child's PID = 1974 ***[OS18] select Stride scheduling class Child's PID = 1975 ***[OS18] select Stride scheduling class Child's PID = 1976 ***[OS18] select Stride scheduling class 3 tasks are created *** DONE *** stride_app$ dmesg grep OS18... [ ] ***[OS18] task is created: pass = 25, stride = 25, tickets = 40 [ ] ***[OS18] Enqueue:::P[1974], nr_running = 1 [ ] ***[OS18] task is created: pass = 50, stride = 50, tickets = 20 [ ] ***[OS18] Enqueue:::P[1975], nr_running = 2 [ ] ***[OS18] task is created: pass = 100, stride = 100, tickets = 10 [ ] ***[OS18] Enqueue:::P[1976], nr_running = 3 [ ] ***[OS18] Pick:::P[1974](stride = 25): pass = 50 [ ] ***[OS18] Tick:::P[1974](stride = 25): pass = 75 [ ] ***[OS18] Pick:::P[1975](stride = 50): pass = 100 [ ] ***[OS18] Pick:::P[1974](stride = 25): pass = 100 [ ] ***[OS18] Tick:::P[1974](stride = 25): pass = 125 [ ] ***[OS18] Pick:::P[1976](stride = 100): pass = 200 [ ] ***[OS18] Pick:::P[1975](stride = 50): pass = 150 [ ] ***[OS18] Pick:::P[1974](stride = 25): pass = 150 [ ] ***[OS18] Tick:::P[1974](stride = 25): pass = 175 [ ] ***[OS18] Pick:::P[1975](stride = 50): pass = 200 [ ] ***[OS18] Pick:::P[1974](stride = 25): pass = 200 [ ] ***[OS18] Tick:::P[1974](stride = 25): pass = 225 [ ] ***[OS18] Pick:::P[1976](stride = 100): pass = 300 [ ] ***[OS18] Pick:::P[1975](stride = 50): pass =

34 34 Remind Scheduler has 1,000 tickets Process #1 (P1): tickets = 40, stride = 25 Process #2 (P2): tickets = 20, stride = 50 Process #3 (P3): tickets = 10, stride = 100 time pass P1.pass P2.pass P3.pass The amount of allocated CPU resources P1 > P2 > P3 The more tickets, the more resources Proportional share scheduling At point Q, P1 get twice than P2, and P2 get twice than P3 Q 34

35 35 35

Linux Scheduler. Minsoo Ryu. Department of Computer Science and Engineering. Hanyang University. Real-Time Computing and Communications Lab.

Linux Scheduler. Minsoo Ryu. Department of Computer Science and Engineering. Hanyang University. Real-Time Computing and Communications Lab. Linux Scheduler Minsoo Ryu Department of Computer Science and Engineering 2 1 Introduction to Linux Scheduler Page X 2 Completely Fair Scheduler (CFS) Page X 3 CFS Implementation in the Kernel Page X 4

More information

SFO The Linux Kernel Scheduler. Viresh Kumar (PMWG)

SFO The Linux Kernel Scheduler. Viresh Kumar (PMWG) SFO17-421 The Linux Kernel Scheduler Viresh Kumar (PMWG) Topics CPU Scheduler The O(1) scheduler Current scheduler design Scheduling classes schedule() Scheduling classes and policies Sched class: STOP

More information

Linux Task Scheduling

Linux Task Scheduling Linux Task Scheduling Hyunmin Yoon (hmyoon@rtcc.hanyang.ac.kr) 2 This document is based-on linux 4.15.6 version (released at 2018.02.26) 2 3 Task Scheduling SCHEDULING CLASS 3 4 Scheduling Class Since

More information

Periodic scheduler for Linux OS. Mike Athanasakis Operating System TA Winter

Periodic scheduler for Linux OS. Mike Athanasakis Operating System TA Winter Periodic scheduler for Linux OS Mike Athanasakis michath@csd.uoc.gr Operating System TA Winter 2015-2016 History Linux v1.2 Round Robin Linux v2.2 Scheduling Classes & Policies Linux v2.4 Division in epochs,

More information

Linux Scheduler. OS 323 (Spring 2013)

Linux Scheduler. OS 323 (Spring 2013) Linux Scheduler OS 323 (Spring 2013) Process states CPU scheduler Makes the computer more productive by switching the CPU among processes CPU scheduling may take place when a process: 1. Switches from

More information

Scheduling II. ! Multilevel queue scheduling. ! Multiprocessor scheduling issues. ! Real-time scheduling. ! Linux scheduling

Scheduling II. ! Multilevel queue scheduling. ! Multiprocessor scheduling issues. ! Real-time scheduling. ! Linux scheduling Scheduling II! Multilevel queue scheduling! Multiprocessor scheduling issues! Real-time scheduling! Linux scheduling 1 Motivation! No one-size-fits-all scheduler " Different workloads " Different environment!

More information

Linux Kernel Development (LKD)

Linux Kernel Development (LKD) Linux Kernel Development (LKD) Session 3 Scheduling and System calls Paulo Baltarejo Sousa pbs@isep.ipp.pt 2017 PBS LKD: S3 1 / 59 Disclaimer Material and Slides Some of the material/slides are adapted

More information

Operating Systems 16 - CS 323 Assignment #2

Operating Systems 16 - CS 323 Assignment #2 Operating Systems 16 - CS 323 Assignment #2 Scheduler March 18, 2016 1 Objectives 1. Learn about scheduling in the Linux kernel 2. Understand the tradeoffs involved in scheduling 3. Work on the codebase

More information

Scheduling: Case Studies. CS 161: Lecture 5 2/14/17

Scheduling: Case Studies. CS 161: Lecture 5 2/14/17 Scheduling: Case Studies CS 161: Lecture 5 2/14/17 Scheduling Basics Goal of scheduling: Pick the best task to run on a CPU Often a good idea to prioritize IO-bound tasks If IO comes from user (e.g., keyboard,

More information

PROCESS SCHEDULING Operating Systems Design Euiseong Seo

PROCESS SCHEDULING Operating Systems Design Euiseong Seo PROCESS SCHEDULING 2017 Operating Systems Design Euiseong Seo (euiseong@skku.edu) Histogram of CPU Burst Cycles Alternating Sequence of CPU and IO Processor Scheduling Selects from among the processes

More information

Linux Kernel Development (LKD)

Linux Kernel Development (LKD) Linux Kernel Development (LKD) Session 2 CISTER Framework: Laboratory 2 Paulo Baltarejo Sousa pbs@isep.ipp.pt 2017 1 Introduction The goal of the CISTER framework is to create a set of tools that help

More information

Project No. 2: Process Scheduling in Linux Submission due: April 12, 2013, 11:59pm

Project No. 2: Process Scheduling in Linux Submission due: April 12, 2013, 11:59pm Project No. 2: Process Scheduling in Linux Submission due: April 12, 2013, 11:59pm PURPOSE Getting familiar with the Linux kernel source code. Understanding process scheduling and how different parameters

More information

Linux Kernel Development (LKD)

Linux Kernel Development (LKD) Linux Kernel Development (LKD) Session 2 Kernel Build System and Process Management Paulo Baltarejo Sousa pbs@isep.ipp.pt 2017 PBS LKD: S2 1 / 41 Disclaimer Material and Slides Some of the material/slides

More information

Load Balancing. Minsoo Ryu. Department of Computer Science and Engineering. Hanyang University. Real-Time Computing and Communications Lab.

Load Balancing. Minsoo Ryu. Department of Computer Science and Engineering. Hanyang University. Real-Time Computing and Communications Lab. Load Balancing Minsoo Ryu Department of Computer Science and Engineering 2 1 Concepts of Load Balancing Page X 2 Load Balancing Algorithms Page X 3 Overhead of Load Balancing Page X 4 Load Balancing in

More information

Operating System. Hanyang University. Hyunmin Yoon Operating System Hanyang University

Operating System. Hanyang University. Hyunmin Yoon Operating System Hanyang University Hyunmin Yoon (fulcanelli86@gmail.com) 2 General concept SCHEDULING 2 3 Process Program consists of processes A process includes Program code Data section Global variables Current activity PC (program counter)

More information

Chap 7, 8: Scheduling. Dongkun Shin, SKKU

Chap 7, 8: Scheduling. Dongkun Shin, SKKU Chap 7, 8: Scheduling 1 Introduction Multiprogramming Multiple processes in the system with one or more processors Increases processor utilization by organizing processes so that the processor always has

More information

进程调度 南京大学计算机系

进程调度 南京大学计算机系 进程调度 张雷 南京大学计算机系 2018-10-30 CPU Scheduler Lab3 Introduction Linux schedulers Idle Scheduler Real-Time Scheduler Completely Fair Scheduler (CFS) Conclusion CPU Scheduler Lab3 Introduction Linux schedulers

More information

238P: Operating Systems. Lecture 14: Process scheduling

238P: Operating Systems. Lecture 14: Process scheduling 238P: Operating Systems Lecture 14: Process scheduling This lecture is heavily based on the material developed by Don Porter Anton Burtsev November, 2017 Cooperative vs preemptive What is cooperative multitasking?

More information

ò Paper reading assigned for next Tuesday ò Understand low-level building blocks of a scheduler User Kernel ò Understand competing policy goals

ò Paper reading assigned for next Tuesday ò Understand low-level building blocks of a scheduler User Kernel ò Understand competing policy goals Housekeeping Paper reading assigned for next Tuesday Scheduling Don Porter CSE 506 Memory Management Logical Diagram Binary Memory Formats Allocators Threads Today s Lecture Switching System to CPU Calls

More information

CPU/Process Management : Objectives & Challenges. Data Structures for CPU Management

CPU/Process Management : Objectives & Challenges. Data Structures for CPU Management CPU/Process Management : Objectives & Challenges Scheduling Determine the order in which processes get to use the CPU Prevent starvation, ensure fairness, be efficient Allow processes to communicate efficiently

More information

Scheduling. Scheduling 1/51

Scheduling. Scheduling 1/51 Scheduling 1/51 Learning Objectives Scheduling To understand the role of a scheduler in an operating system To understand the scheduling mechanism To understand scheduling strategies such as non-preemptive

More information

Scheduling, part 2. Don Porter CSE 506

Scheduling, part 2. Don Porter CSE 506 Scheduling, part 2 Don Porter CSE 506 Logical Diagram Binary Memory Formats Allocators Threads Today s Lecture Switching System to CPU Calls RCU scheduling File System Networking Sync User Kernel Memory

More information

ò mm_struct represents an address space in kernel ò task represents a thread in the kernel ò A task points to 0 or 1 mm_structs

ò mm_struct represents an address space in kernel ò task represents a thread in the kernel ò A task points to 0 or 1 mm_structs Last time We went through the high-level theory of scheduling algorithms Scheduling Today: View into how Linux makes its scheduling decisions Don Porter CSE 306 Lecture goals Understand low-level building

More information

Linux Linux #! "! Linux

Linux Linux #! ! Linux #!! ! 2.5.X % Understanding the Kernel &! 2.5.X kernel/sched.cinclude/linux/sched.h'! Ingo Molnar' ) time! sharing!! &! & Preemptive multitasking SCHED_OTHER * ( & *& real-time!!, & '!! ) TASK_RUNNING!

More information

Towards Achieving Fairness in the Linux Scheduler

Towards Achieving Fairness in the Linux Scheduler Towards Achieving Fairness in the Linux Scheduler Chee Siang Wong, Ian Tan, Rosalind Deena Kumari Faculty of Information Technology, Multimedia University, 63100 Cyberjaya, Selangor, Malaysia +60-13-3996255,

More information

Scheduling. Don Porter CSE 306

Scheduling. Don Porter CSE 306 Scheduling Don Porter CSE 306 Last time ò We went through the high-level theory of scheduling algorithms ò Today: View into how Linux makes its scheduling decisions Lecture goals ò Understand low-level

More information

Scheduling. Scheduling 1/51

Scheduling. Scheduling 1/51 Scheduling 1/51 Scheduler Scheduling Scheduler allocates cpu(s) to threads and processes. This action is known as scheduling. The scheduler is a part of the process manager code that handles scheduling.

More information

Scalable Linux Scheduling (Paper # 9)

Scalable Linux Scheduling (Paper # 9) Scalable Linux Scheduling (Paper # 9) Scalability: the ability to support large number of threads. 30% of the total CPU time is spent in the scheduler when the number of running threads is high. Linux

More information

Proxy Execution. Peter Zijlstra Intel OTC

Proxy Execution. Peter Zijlstra Intel OTC Proxy Execution Peter Zijlstra Intel OTC Why Scheduler dependent inheritance schemes: Static priority; FIFO/RR Priority inheritance Job priority; DEADLINE Deadline inheritance; insufficient Bandwidth inheritance;

More information

High level scheduling: Medium level scheduling: Low level scheduling. Scheduling 0 : Levels

High level scheduling: Medium level scheduling: Low level scheduling. Scheduling 0 : Levels Scheduling 0 : Levels High level scheduling: Deciding whether another process can run is process table full? user process limit reached? load to swap space or memory? Medium level scheduling: Balancing

More information

Linux Kernel Development (LKD)

Linux Kernel Development (LKD) Linux Kernel Development (LKD) Session 3 CISTER Framework: Laboratory Paulo Baltarejo Sousa pbs@isep.ipp.pt 2017 1 LIFO Scheduling Algorithm It will be added a new scheduling policy to the CISTER framework.

More information

EECS 750: Advanced Operating Systems. 01/29 /2014 Heechul Yun

EECS 750: Advanced Operating Systems. 01/29 /2014 Heechul Yun EECS 750: Advanced Operating Systems 01/29 /2014 Heechul Yun 1 Administrative Next summary assignment Resource Containers: A New Facility for Resource Management in Server Systems, OSDI 99 due by 11:59

More information

CSCI-GA Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke

CSCI-GA Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke CSCI-GA.2250-001 Operating Systems Lecture 3: Processes and Threads -Part 2 Scheduling Hubertus Franke frankeh@cs.nyu.edu Processes Vs Threads The unit of dispatching is referred to as a thread or lightweight

More information

Process management. Scheduling

Process management. Scheduling Process management Scheduling Points of scheduler invocation (recap) User Kernel Return from system call Process Schedule Return from interrupt handler Timer interrupts to ensure OS control Return from

More information

Per-entity Load Tracking

Per-entity Load Tracking Per-entity Load Tracking Hyunmin Yoon 어코드사업단 리눅스 CFS 와로드밸런서 교육 2 Per-entity Load Tracking Purpose Fair and responsive scheduling Maximizing system throughput Minimizing power consumption Problem of previous

More information

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission 1

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission 1 Process Heechul Yun Disclaimer: some slides are adopted from the book authors slides with permission 1 Recap OS services Resource (CPU, memory) allocation, filesystem, communication, protection, security,

More information

CS 4284 Systems Capstone. Resource Allocation & Scheduling Godmar Back

CS 4284 Systems Capstone. Resource Allocation & Scheduling Godmar Back CS 4284 Systems Capstone Resource Allocation & Scheduling Godmar Back Resource Allocation and Scheduling Resource Allocation & Scheduling Resource management is primary OS function Involves resource allocation

More information

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission Process Heechul Yun Disclaimer: some slides are adopted from the book authors slides with permission 1 Recap OS services Resource (CPU, memory) allocation, filesystem, communication, protection, security,

More information

Advanced Operating Systems (CS 202) Scheduling (2)

Advanced Operating Systems (CS 202) Scheduling (2) Advanced Operating Systems (CS 202) Scheduling (2) Lottery Scheduling 2 2 2 Problems with Traditional schedulers Priority systems are ad hoc: highest priority always wins Try to support fair share by adjusting

More information

Ineffective and effective way to find out latency bottlenecks by Ftrace

Ineffective and effective way to find out latency bottlenecks by Ftrace Ineffective and effective way to find out latency bottlenecks by Ftrace Yoshitake Kobayashi Advanced Software Technology Group Corporate Software Engineering Center TOSHIBA CORPORATION 16 Feb, 212 Copyright

More information

Chapter 5 Scheduling

Chapter 5 Scheduling Chapter 5 Scheduling Images from Silberschatz Pacific University 1 Life time of a single process CPU usage/io bursts What would an IO bound process look like? What would a CPU bound process look like?

More information

CSCI 8530 Advanced Operating Systems. Part 10 Clock and Timer Management

CSCI 8530 Advanced Operating Systems. Part 10 Clock and Timer Management CSCI 8530 Advanced Operating Systems Part 10 Clock and Timer Management Updated 10/11/2016 Location of Clock Management in the Hierarchy Clock Hardware Processor clock Controls processor rate Often cited

More information

Analysis of the BFS Scheduler in FreeBSD

Analysis of the BFS Scheduler in FreeBSD CS2106R Final Report Analysis of the BFS Scheduler in FreeBSD By Vaarnan Drolia Department of Computer Science School of Computing National University of Singapore 2011/12 CS2106R Final Report Analysis

More information

CFS-v: I/O Demand-driven VM Scheduler in KVM

CFS-v: I/O Demand-driven VM Scheduler in KVM CFS-v: Demand-driven VM Scheduler in KVM Hyotaek Shim and Sung-Min Lee (hyotaek.shim, sung.min.lee@samsung.com) Software R&D Center, Samsung Electronics 2014. 10. 16 Problem in Server Consolidation 2/16

More information

Scheduling - Overview

Scheduling - Overview Scheduling - Overview Quick review of textbook scheduling Linux 2.4 scheduler implementation overview Linux 2.4 scheduler code Modified Linux 2.4 scheduler Linux 2.6 scheduler comments Possible Goals of

More information

Comparison of soft real-time CPU scheduling in Linux kernel 2.6 series with Solaris 10

Comparison of soft real-time CPU scheduling in Linux kernel 2.6 series with Solaris 10 Comparison of soft real-time CPU scheduling in Linux kernel 2.6 series with Solaris 10 Kristoffer Eriksson Philip Frising Department of Computer and Information Science Linköping University 1(15) 1. About

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Fall 2017 Lecture 10 Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 Chapter 6: CPU Scheduling Basic Concepts

More information

Asynchronous Events on Linux

Asynchronous Events on Linux Asynchronous Events on Linux Frederic.Rossi@Ericsson.CA Open System Lab Systems Research June 25, 2002 Ericsson Research Canada Introduction Linux performs well as a general purpose OS but doesn t satisfy

More information

A Survey on Fairness and Performance Analysis of Completely Fair Scheduler in Linux Kernel

A Survey on Fairness and Performance Analysis of Completely Fair Scheduler in Linux Kernel International Journal of Control Theory and Applications ISSN : 0974-5572 International Science Press Volume 9 Number 44 2016 A Survey on Fairness and Performance Analysis of Completely Fair Scheduler

More information

Operating Systems. Process scheduling. Thomas Ropars.

Operating Systems. Process scheduling. Thomas Ropars. 1 Operating Systems Process scheduling Thomas Ropars thomas.ropars@univ-grenoble-alpes.fr 2018 References The content of these lectures is inspired by: The lecture notes of Renaud Lachaize. The lecture

More information

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou ( Zhejiang University

CPU Scheduling. Operating Systems (Fall/Winter 2018) Yajin Zhou (  Zhejiang University Operating Systems (Fall/Winter 2018) CPU Scheduling Yajin Zhou (http://yajin.org) Zhejiang University Acknowledgement: some pages are based on the slides from Zhi Wang(fsu). Review Motivation to use threads

More information

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013)

CPU Scheduling. Daniel Mosse. (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013) CPU Scheduling Daniel Mosse (Most slides are from Sherif Khattab and Silberschatz, Galvin and Gagne 2013) Basic Concepts Maximum CPU utilization obtained with multiprogramming CPU I/O Burst Cycle Process

More information

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13

PROCESS SCHEDULING II. CS124 Operating Systems Fall , Lecture 13 PROCESS SCHEDULING II CS124 Operating Systems Fall 2017-2018, Lecture 13 2 Real-Time Systems Increasingly common to have systems with real-time scheduling requirements Real-time systems are driven by specific

More information

Scheduling policy. Reference: ULK3e 7.1. Scheduling in Linux 1 / 20

Scheduling policy. Reference: ULK3e 7.1. Scheduling in Linux 1 / 20 Scheduling policy Reference: ULK3e 7.1. Goals fast process response time good throughput for background jobs avoidance of process starvation reconciliation of needs of low- and high-priority processes

More information

[537] Locks. Tyler Harter

[537] Locks. Tyler Harter [537] Locks Tyler Harter Review: Threads+Locks CPU 1 CPU 2 running thread 1 running thread 2 RAM PageDir A PageDir B CPU 1 CPU 2 running thread 1 running thread 2 RAM PageDir A PageDir B Virt Mem (PageDir

More information

Operating System. Hanyang University. Hyunmin Yoon Operating System Hanyang University

Operating System. Hanyang University. Hyunmin Yoon Operating System Hanyang University Hyunmin Yoon (fulcanelli86@gmail.com) 2 Interrupt vs. Polling INTERRUPT 2 3 Polling (Programmed I/O) Processor has direct control over I/O Processor waits for I/O module to complete operation Processor

More information

W4118: advanced scheduling

W4118: advanced scheduling W4118: advanced scheduling Instructor: Junfeng Yang References: Modern Operating Systems (3 rd edition), Operating Systems Concepts (8 th edition), previous W4118, and OS at MIT, Stanford, and UWisc Outline

More information

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017 CS 471 Operating Systems Yue Cheng George Mason University Fall 2017 Outline o Process concept o Process creation o Process states and scheduling o Preemption and context switch o Inter-process communication

More information

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition

Chapter 6: CPU Scheduling. Operating System Concepts 9 th Edition Chapter 6: CPU Scheduling Silberschatz, Galvin and Gagne 2013 Chapter 6: CPU Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Real-Time

More information

CS 5204 Midterm 1 Solutions

CS 5204 Midterm 1 Solutions CS 5204 Midterm 1 Solutions 16 Students took the midterm. The table below shows the results for each problem. Problem 1 2 3 4 Total Average 2.9 15.9 16.8 19.3 54.8 StDev 3.5 6.7 4.1 9.1 15.2 Median 2 17

More information

CS 326: Operating Systems. CPU Scheduling. Lecture 6

CS 326: Operating Systems. CPU Scheduling. Lecture 6 CS 326: Operating Systems CPU Scheduling Lecture 6 Today s Schedule Agenda? Context Switches and Interrupts Basic Scheduling Algorithms Scheduling with I/O Symmetric multiprocessing 2/7/18 CS 326: Operating

More information

Computer Systems Laboratory Sungkyunkwan University

Computer Systems Laboratory Sungkyunkwan University CPU Scheduling Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Today s Topics General scheduling concepts Scheduling algorithms Case studies Linux

More information

Thread and Synchronization

Thread and Synchronization Thread and Synchronization Task Model (Module 18) Yann-Hang Lee Arizona State University yhlee@asu.edu (480) 727-7507 Summer 2014 Real-time Systems Lab, Computer Science and Engineering, ASU Why Talk About

More information

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems Processes CS 475, Spring 2018 Concurrent & Distributed Systems Review: Abstractions 2 Review: Concurrency & Parallelism 4 different things: T1 T2 T3 T4 Concurrency: (1 processor) Time T1 T2 T3 T4 T1 T1

More information

Lecture 3: Processes. CMPUT 379, Section A1, Winter 2014 January 13, 15 and 17

Lecture 3: Processes. CMPUT 379, Section A1, Winter 2014 January 13, 15 and 17 Lecture 3: Processes CMPUT 379, Section A1, Winter 2014 January 13, 15 and 17 Objectives Understand the notion of a process : a program in execution which forms the basis of all computation Understand

More information

Interrupts and Time. Real-Time Systems, Lecture 5. Martina Maggio 28 January Lund University, Department of Automatic Control

Interrupts and Time. Real-Time Systems, Lecture 5. Martina Maggio 28 January Lund University, Department of Automatic Control Interrupts and Time Real-Time Systems, Lecture 5 Martina Maggio 28 January 2016 Lund University, Department of Automatic Control Content [Real-Time Control System: Chapter 5] 1. Interrupts 2. Clock Interrupts

More information

Operating System Project / Lecture 1 Tasks and scheduling. Bon Keun Seo

Operating System Project / Lecture 1 Tasks and scheduling. Bon Keun Seo Operating System Project / Lecture 1 Tasks and scheduling Bon Keun Seo Program: executable code Program and process Process: a running instance of a program /bin/bash Program (bash) Process 1 (bash) Process

More information

Term Project Phase II: The Scheduler Ter m Proj ect Phas e II:

Term Project Phase II: The Scheduler Ter m Proj ect Phas e II: cse331 fall 2011 Term Project Phase II: The Scheduler Ter m Proj ect Phas e II: Goal: You will Iearn more about how process management is designed, particularly how the scheduler is implemented. The scheduler

More information

CS2506 Quick Revision

CS2506 Quick Revision CS2506 Quick Revision OS Structure / Layer Kernel Structure Enter Kernel / Trap Instruction Classification of OS Process Definition Process Context Operations Process Management Child Process Thread Process

More information

Interrupts and Time. Interrupts. Content. Real-Time Systems, Lecture 5. External Communication. Interrupts. Interrupts

Interrupts and Time. Interrupts. Content. Real-Time Systems, Lecture 5. External Communication. Interrupts. Interrupts Content Interrupts and Time Real-Time Systems, Lecture 5 [Real-Time Control System: Chapter 5] 1. Interrupts 2. Clock Interrupts Martina Maggio 25 January 2017 Lund University, Department of Automatic

More information

Processes, Context Switching, and Scheduling. Kevin Webb Swarthmore College January 30, 2018

Processes, Context Switching, and Scheduling. Kevin Webb Swarthmore College January 30, 2018 Processes, Context Switching, and Scheduling Kevin Webb Swarthmore College January 30, 2018 Today s Goals What is a process to the OS? What are a process s resources and how does it get them? In particular:

More information

[537] Locks and Condition Variables. Tyler Harter

[537] Locks and Condition Variables. Tyler Harter [537] Locks and Condition Variables Tyler Harter Review: using and designing basic locks Do it. Problem 1 Lock Evaluation How to tell if a lock implementation is good? Lock Evaluation How to tell if a

More information

CS370 Operating Systems

CS370 Operating Systems CS370 Operating Systems Colorado State University Yashwant K Malaiya Spring 2019 Lecture 8 Scheduling Slides based on Text by Silberschatz, Galvin, Gagne Various sources 1 1 FAQ POSIX: Portable Operating

More information

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Processes and threads ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective Part I: Operating system overview: Processes and threads 1 Overview Process concept Process scheduling Thread

More information

Task Scheduling of Real- Time Media Processing with Hardware-Assisted Virtualization Heikki Holopainen

Task Scheduling of Real- Time Media Processing with Hardware-Assisted Virtualization Heikki Holopainen Task Scheduling of Real- Time Media Processing with Hardware-Assisted Virtualization Heikki Holopainen Aalto University School of Electrical Engineering Degree Programme in Communications Engineering Supervisor:

More information

Chapter 5: CPU Scheduling. Operating System Concepts 9 th Edit9on

Chapter 5: CPU Scheduling. Operating System Concepts 9 th Edit9on Chapter 5: CPU Scheduling Operating System Concepts 9 th Edit9on Silberschatz, Galvin and Gagne 2013 Chapter 6: CPU Scheduling 1. Basic Concepts 2. Scheduling Criteria 3. Scheduling Algorithms 4. Thread

More information

Scheduling. CS 161: Lecture 4 2/9/17

Scheduling. CS 161: Lecture 4 2/9/17 Scheduling CS 161: Lecture 4 2/9/17 Where does the first process come from? The Linux Boot Process Machine turned on; BIOS runs BIOS: Basic Input/Output System Stored in flash memory on motherboard Determines

More information

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu CPSC 341 OS & Networks Processes Dr. Yingwu Zhu Process Concept Process a program in execution What is not a process? -- program on a disk A process is an active object, but a program is just a file It

More information

Section 7: Scheduling and Fairness

Section 7: Scheduling and Fairness March 1-2, 2018 Contents 1 Warmup 2 2 Vocabulary 2 3 Problems 3 3.1 Scheduling............................................. 3 3.2 Simple Priority Scheduler.................................... 4 3.2.1 Fairness..........................................

More information

Chapter 5: Process Scheduling

Chapter 5: Process Scheduling Chapter 5: Process Scheduling Chapter 5: Process Scheduling Basic Concepts Scheduling Criteria Scheduling Algorithms Thread Scheduling Multiple-Processor Scheduling Real-Time CPU Scheduling Operating Systems

More information

Published By NYLXS Author: Fernando Gutierrez, Ruben Safr ISBN Copyright 2015 under the GPL FDL by NYLXS

Published By NYLXS  Author: Fernando Gutierrez, Ruben Safr ISBN Copyright 2015 under the GPL FDL by NYLXS 1 2 Published By NYLXS http://www.mrbrklyn.com Author: Fernando Gutierrez, Ruben Safr ISBN 978-1-329-11030-4 Copyright 2015 under the GPL FDL by NYLXS Spring is here, and after a very cold winter, activities

More information

Evaluation of Real-time Performance in Embedded Linux. Hiraku Toyooka, Hitachi. LinuxCon Europe Hitachi, Ltd All rights reserved.

Evaluation of Real-time Performance in Embedded Linux. Hiraku Toyooka, Hitachi. LinuxCon Europe Hitachi, Ltd All rights reserved. Evaluation of Real-time Performance in Embedded Linux LinuxCon Europe 2014 Hiraku Toyooka, Hitachi 1 whoami Hiraku Toyooka Software engineer at Hitachi " Working on operating systems Linux (mainly) for

More information

Linux (Fedora or Slackware) CPU Scheduling

Linux (Fedora or Slackware) CPU Scheduling Linux (Fedora or Slackware) CPU Scheduling DHEYAULDEEN MAHMOOD Student no. 163104411 Department: IT Submit to Prof.Dr.Hassan Huseyin Balik Outline Introduction Linux Fedora CPU scheduler in Linux fedora

More information

CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. Dispatcher. CPU Scheduler. Alternating Sequence of CPU and I/O Bursts

CPU Scheduling. Basic Concepts. Histogram of CPU-burst Times. Dispatcher. CPU Scheduler. Alternating Sequence of CPU and I/O Bursts CS307 Basic Concepts Maximize CPU utilization obtained with multiprogramming CPU Scheduling CPU I/O Burst Cycle Process execution consists of a cycle of CPU execution and I/O wait CPU burst distribution

More information

Context Switching & CPU Scheduling

Context Switching & CPU Scheduling Context Switching & CPU Scheduling Nima Honarmand Administrivia Midterm: next Tuesday, 10/17, in class Will include everything discussed until then Will cover: Class lectures, slides and discussions All

More information

Native POSIX Thread Library (NPTL) CSE 506 Don Porter

Native POSIX Thread Library (NPTL) CSE 506 Don Porter Native POSIX Thread Library (NPTL) CSE 506 Don Porter Logical Diagram Binary Memory Threads Formats Allocators Today s Lecture Scheduling System Calls threads RCU File System Networking Sync User Kernel

More information

Recap. Run to completion in order of arrival Pros: simple, low overhead, good for batch jobs Cons: short jobs can stuck behind the long ones

Recap. Run to completion in order of arrival Pros: simple, low overhead, good for batch jobs Cons: short jobs can stuck behind the long ones Recap First-Come, First-Served (FCFS) Run to completion in order of arrival Pros: simple, low overhead, good for batch jobs Cons: short jobs can stuck behind the long ones Round-Robin (RR) FCFS with preemption.

More information

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski

Operating Systems Design Fall 2010 Exam 1 Review. Paul Krzyzanowski Operating Systems Design Fall 2010 Exam 1 Review Paul Krzyzanowski pxk@cs.rutgers.edu 1 Question 1 To a programmer, a system call looks just like a function call. Explain the difference in the underlying

More information

Problem Set 2. CS347: Operating Systems

Problem Set 2. CS347: Operating Systems CS347: Operating Systems Problem Set 2 1. Consider a clinic with one doctor and a very large waiting room (of infinite capacity). Any patient entering the clinic will wait in the waiting room until the

More information

ECEN 449 Microprocessor System Design. Hardware-Software Communication. Texas A&M University

ECEN 449 Microprocessor System Design. Hardware-Software Communication. Texas A&M University ECEN 449 Microprocessor System Design Hardware-Software Communication 1 Objectives of this Lecture Unit Learn basics of Hardware-Software communication Memory Mapped I/O Polling/Interrupts 2 Motivation

More information

Review: Program Execution. Memory program code program data program stack containing procedure activation records

Review: Program Execution. Memory program code program data program stack containing procedure activation records Threads and Concurrency 1 Review: Program Execution Registers program counter, stack pointer,... Memory program code program data program stack containing procedure activation records CPU fetches and executes

More information

Scheduling II. Today. Next Time. ! Proportional-share scheduling! Multilevel-feedback queue! Multiprocessor scheduling. !

Scheduling II. Today. Next Time. ! Proportional-share scheduling! Multilevel-feedback queue! Multiprocessor scheduling. ! Scheduling II Today! Proportional-share scheduling! Multilevel-feedback queue! Multiprocessor scheduling Next Time! Memory management Scheduling with multiple goals! What if you want both good turnaround

More information

Processes. Overview. Processes. Process Creation. Process Creation fork() Processes. CPU scheduling. Pål Halvorsen 21/9-2005

Processes. Overview. Processes. Process Creation. Process Creation fork() Processes. CPU scheduling. Pål Halvorsen 21/9-2005 INF060: Introduction to Operating Systems and Data Communication Operating Systems: Processes & CPU Pål Halvorsen /9-005 Overview Processes primitives for creation and termination states context switches

More information

T. Cucinotta Real-Time Systems Lab (ReTiS) Scuola Superiore Sant'Anna Pisa Italy 1. Real-Time Scheduling on Linux and SCHED_DEADLINE

T. Cucinotta Real-Time Systems Lab (ReTiS) Scuola Superiore Sant'Anna Pisa Italy 1. Real-Time Scheduling on Linux and SCHED_DEADLINE T. Cucinotta Real-Time Systems Lab (ReTiS) Scuola Superiore Sant'Anna Pisa Italy 1 Real-Time Scheduling on Linux and SCHED_DEADLINE Linux CPU Schedulers Scheduling classes and policies Classes listed in

More information

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s)

CPU Scheduling. The scheduling problem: When do we make decision? - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s) CPU Scheduling The scheduling problem: - Have K jobs ready to run - Have N 1 CPUs - Which jobs to assign to which CPU(s) When do we make decision? 1 / 39 CPU Scheduling new admitted interrupt exit terminated

More information

Scheduling in the Supermarket

Scheduling in the Supermarket Scheduling in the Supermarket Consider a line of people waiting in front of the checkout in the grocery store. In what order should the cashier process their purchases? Scheduling Criteria CPU utilization

More information

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo PROCESS MANAGEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication

More information

Last time: introduction. Networks and Operating Systems ( ) Chapter 2: Processes. This time. General OS structure. The kernel is a program!

Last time: introduction. Networks and Operating Systems ( ) Chapter 2: Processes. This time. General OS structure. The kernel is a program! ADRIAN PERRIG & TORSTEN HOEFLER Networks and Operating Systems (252-0062-00) Chapter 2: Processes Last time: introduction Introduction: Why? February 12, 2016 Roles of the OS Referee Illusionist Glue Structure

More information

Analyzing the impact of sysctl scheduler tunables

Analyzing the impact of sysctl scheduler tunables Ciju Rajan K [cijurajan@in.ibm.com] Linux Technology Center Analyzing the impact of sysctl scheduler tunables LinuxCon, Vancouver 2011 Agenda Introduction to scheduler tunables How to tweak the scheduler

More information

CS 378 (Spring 2003)

CS 378 (Spring 2003) Department of Computer Sciences THE UNIVERSITY OF TEXAS AT AUSTIN CS 378 (Spring 2003) Linux Kernel Programming Yongguang Zhang (ygz@cs.utexas.edu) Copyright 2003, Yongguang Zhang This Lecture Last Lecture:

More information