SlideShare a Scribd company logo
Tasklet Vs Work queues
By
Rajkumar Rampelli
Outline
•
•
•
•
•
•

Deferrable functions
Top Half Vs Bottom Half
Tasklet
Work queue
Tasklet Vs Work queue
Conclusion

12/6/2013

Raj Kumar Rampelli

2
Deferrable function
• Mechanism for supporting the delayed execution of any function in
Interrupt handlers (Interrupt context)
• Interrupt Context
– Kernel enters Interrupt context when hardware interrupt received
– Kernel enters Process/Kernel context from Interrupt context after
servicing the hardware interrupt
– Execution of tasks in Interrupt context should be minimized
• Why - Majority of Interrupts are disabled, therefore latency to handle other
interrupts will be increased
• Solution: Move execution of not urgent function (piece of code) into process
context (Deferrable function)
• Add deferrable functions in Interrupt Handlers

• Deferrable functions: can be executed in process context
– Tasklet
– Work queues

12/6/2013

Raj Kumar Rampelli

3
Top Half Vs Bottom Half
Top Half

Bottom Half

Processing of tasks in Interrupt Handler
(Interrupt context)

Processing of tasks in Kernel context

Interrupts are disabled

Interrupts are not disabled

Add Deferrable functions for delayed
execution

Handles Deferrable functions

Processing time should be less

-NA-

Uses Tasklets and work queue APIs for deferrable mechanism

12/6/2013

Raj Kumar Rampelli

4
Tasklet: To schedule the work (function) to run later point of time
so that reducing the amount of work done in interrupt handlers.
Tasklet Initialization APIs

Usage

void tasklet_function (unsigned
long data);

Deferrable function i.e. actual Task

DECLARE_TASKLET
(tasklet_name,
tasklet_function, tasklet_data);

• Initializes the tasklet structure (tasklet_struct)
with passing argument list
• Tasklets are enabled by default
• Next step: Schedule the task

DECLARE_TASKLET_DISABLED
(tasklet_name,
tasklet_function, tasklet_data);

• Initializes the tasklet structure
• Tasklets are disabled
• Next step: Enable Tasklet before schedule the
task

void tasklet_init(struct
tasklet_struct *, void (*func)
(unsigned long), unsigned long
data);

• Initializes the tasklet structure (tasklet_struct)
with passing argument list

12/6/2013

Raj Kumar Rampelli

5
Tasklet (contd.)
Tasklet Enable/Disable APIs

Usage

void tasklet_enable (struct tasklet_struct *);

/* Enable normal priority scheduling */

void tasklet_disable (struct tasklet_struct *);

/* returns after disabling the tasklet */

void tasklet_hi_enable (struct tasklet_struct *); /* Enabling High priority scheduling */
void tasklet_disable_nosync (struct
tasklet_struct *);

12/6/2013

/* May returns before termination i.e.
no synchronization with disabling of
tasklet */

Raj Kumar Rampelli

6
Tasklet (contd.)
Tasklet Schedule APIs

Usage

void tasklet_schedule (struct tasklet_struct *);

/* Normal priority scheduling */

void tasklet_hi_schedule (struct tasklet_struct *);

/* Higher priority scheduling */

CPU maintains the normal and high priority softirq vectors lists (normal priority vector
list and high priority vector list) where these functions are queued.
If the function is higher priority function then it is en-queued in higher priority softirq
vector list and similar case for normal priority functions.

Kill a Tasklet

Usage

void tasklet_kill (struct tasklet_struct *);

/* Kill a tasklet */

void tasklet_hi_kill (struct tasklet_struct *);

/* Kill the tasklet and ensure they
would never run */

12/6/2013

Raj Kumar Rampelli

7
Work queue
• Added in linux kernel 2.6 version
• Use two data structures
– struct workqueue_struct
• Work is queued here in Interrupt context
• The same work is executed in Kernel context
– struct work_struct
• Identifies the work and deferrable function
• Kernel threads named "events/X" will extract work from the core work
queue and activates the work's handler function.
Tasklet
Added in linux kernel 2.3
version

In 2.6 kernel version

Sleep in Handler function 
Not possible
12/6/2013

Work queue

Possible.

Latency is less

Raj Kumar Rampelli

More compared to Tasklet

8
Work queue APIs
Create and destroy work queue structure

Usage

struct workqueue_struct
*create_workqueue(name);

/* Creates core workqueue */

void destroy_workqueue(struct
workqueue_struct *);

/* Destroy the workqueue */

Initialization of work structure

Usage

INIT_WORK(work, function);

/* Initializes the work structure with
function handler */

INIT_DELAYED_WORK(work, function);
/* Add any delay before adding this work
INIT_DELAYED_WORK_DEFERRABLE(work, into work queue structure */
function);

12/6/2013

Raj Kumar Rampelli

9
Work queue APIs (contd.)
•

Add work on to work queue
– int queue_work (struct workqueue_struct *wq, struct work_struct *work);
– /* specify the CPU on which the handler should run */
int queue_work_on (int cpu, struct workqueue_struct *wq, struct work_struct *work);
– /* Queue specified work on to specified work queue after delay */
int queue_delayed_work (struct workqueue_struct *wq, struct delayed_work *work, unsigned
long delay);
– int queue_delayed_work_on (int cpu, struct workqueue_struct *wq, struct delayed_work
*work), unsigned long delay);

•

The below functions doesn't require workqueue structure defined. Since, they
uses kernel-global work queue. So, no need to pass workqueue_struct in the
argument list.
–
–
–
–

12/6/2013

int schedule_work (struct work_struct *):
int schedule_work_on (int cpu, struct work_struct *):
int scheduled_delayed_work (struct delayed_work *, unsigned long delay);
int scheduled_delayed_work_on (int cpu, struct delayed_work *, unsigned long delay);

Raj Kumar Rampelli

10
Work queue APIs (contd.)
• Cancel work
/* terminate work in the queue, which is not already executing in the handler */
int cancel_work_sync (struct work_struct *);
int cancel_delayed_work_sync (struct delayed_work *);
• Flush work
Below functions are used to flush the work and works in the specified workqueue.
/* Flush a particular work and block until it is completed */
int flush_work (struct work_struct *);
/* Flush all works in given workqueue and block until it is completed */
int flush_workqueue (struct workqueue_struct *);
/* Flush kernel-global work queue */
void flush_scheduled_work (void);
• Status of work
We can use below two functions to know whether the given work is pending i.e. its handler function is
not yet started.
work_pending(work);
delayed_work_pending (work);

12/6/2013

Raj Kumar Rampelli

11
Conclusion
• Reduce the execution time in Interrupt context by using deferrable
function mechanism
• Top Half: Processing of tasks in Interrupt Handler (Interrupt
context)
• Bottom Half: Processing of tasks in Kernel/Process context
• Two type of deferrable functions
– Tasklet
– Work queue

• Aim: To schedule the work/function (not urgent piece of code) in
interrupt handler to run later point of time (in bottom half) so that
reducing the amount of work done in interrupt handlers.
• Tasklet and Work queue both do the above task using their own set
of APIs
• For more details visit: www.practicepeople.blogspot.com
12/6/2013

Raj Kumar Rampelli

12
THANK YOU 

12/6/2013

Raj Kumar Rampelli

13

More Related Content

What's hot

Root file system
Root file systemRoot file system
Root file system
Bindu U
 
USB Drivers
USB DriversUSB Drivers
USB Drivers
Anil Kumar Pugalia
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
RuggedBoardGroup
 
Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
Amr Ali (ISTQB CTAL Full, CSM, ITIL Foundation)
 
Linux boot process
Linux boot processLinux boot process
Linux boot process
Archana Chandrasekharan
 
Linux kernel memory allocators
Linux kernel memory allocatorsLinux kernel memory allocators
Linux kernel memory allocators
Hao-Ran Liu
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_BootingRashila Rr
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoCMacpaul Lin
 
Slab Allocator in Linux Kernel
Slab Allocator in Linux KernelSlab Allocator in Linux Kernel
Slab Allocator in Linux Kernel
Adrian Huang
 
XPDDS17: PL011 UART Emulation in Xen on ARM - Bhupinder Thakur, Qualcomm Data...
XPDDS17: PL011 UART Emulation in Xen on ARM - Bhupinder Thakur, Qualcomm Data...XPDDS17: PL011 UART Emulation in Xen on ARM - Bhupinder Thakur, Qualcomm Data...
XPDDS17: PL011 UART Emulation in Xen on ARM - Bhupinder Thakur, Qualcomm Data...
The Linux Foundation
 
Linux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell ScriptingLinux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell Scripting
Emertxe Information Technologies Pvt Ltd
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequenceHoucheng Lin
 
Linux watchdog timer
Linux watchdog timerLinux watchdog timer
Linux watchdog timer
RajKumar Rampelli
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
shimosawa
 
Android Storage - Vold
Android Storage - VoldAndroid Storage - Vold
Android Storage - Vold
William Lee
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
Tushar B Kute
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
linuxlab_conf
 
spinlock.pdf
spinlock.pdfspinlock.pdf
spinlock.pdf
Adrian Huang
 

What's hot (20)

Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Root file system
Root file systemRoot file system
Root file system
 
USB Drivers
USB DriversUSB Drivers
USB Drivers
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
Embedded linux network device driver development
Embedded linux network device driver developmentEmbedded linux network device driver development
Embedded linux network device driver development
 
Linux boot process
Linux boot processLinux boot process
Linux boot process
 
Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Linux kernel memory allocators
Linux kernel memory allocatorsLinux kernel memory allocators
Linux kernel memory allocators
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
Slab Allocator in Linux Kernel
Slab Allocator in Linux KernelSlab Allocator in Linux Kernel
Slab Allocator in Linux Kernel
 
XPDDS17: PL011 UART Emulation in Xen on ARM - Bhupinder Thakur, Qualcomm Data...
XPDDS17: PL011 UART Emulation in Xen on ARM - Bhupinder Thakur, Qualcomm Data...XPDDS17: PL011 UART Emulation in Xen on ARM - Bhupinder Thakur, Qualcomm Data...
XPDDS17: PL011 UART Emulation in Xen on ARM - Bhupinder Thakur, Qualcomm Data...
 
Linux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell ScriptingLinux systems - Linux Commands and Shell Scripting
Linux systems - Linux Commands and Shell Scripting
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
Linux watchdog timer
Linux watchdog timerLinux watchdog timer
Linux watchdog timer
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Android Storage - Vold
Android Storage - VoldAndroid Storage - Vold
Android Storage - Vold
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
spinlock.pdf
spinlock.pdfspinlock.pdf
spinlock.pdf
 

Viewers also liked

Learn python – for beginners
Learn python – for beginnersLearn python – for beginners
Learn python – for beginners
RajKumar Rampelli
 
Introduction to Kernel and Device Drivers
Introduction to Kernel and Device DriversIntroduction to Kernel and Device Drivers
Introduction to Kernel and Device Drivers
RajKumar Rampelli
 
Linux GIT commands
Linux GIT commandsLinux GIT commands
Linux GIT commands
RajKumar Rampelli
 
System Booting Process overview
System Booting Process overviewSystem Booting Process overview
System Booting Process overview
RajKumar Rampelli
 
Network security and cryptography
Network security and cryptographyNetwork security and cryptography
Network security and cryptography
RajKumar Rampelli
 
Linux Kernel I/O Schedulers
Linux Kernel I/O SchedulersLinux Kernel I/O Schedulers
Linux Kernel I/O Schedulers
RajKumar Rampelli
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2
RajKumar Rampelli
 

Viewers also liked (7)

Learn python – for beginners
Learn python – for beginnersLearn python – for beginners
Learn python – for beginners
 
Introduction to Kernel and Device Drivers
Introduction to Kernel and Device DriversIntroduction to Kernel and Device Drivers
Introduction to Kernel and Device Drivers
 
Linux GIT commands
Linux GIT commandsLinux GIT commands
Linux GIT commands
 
System Booting Process overview
System Booting Process overviewSystem Booting Process overview
System Booting Process overview
 
Network security and cryptography
Network security and cryptographyNetwork security and cryptography
Network security and cryptography
 
Linux Kernel I/O Schedulers
Linux Kernel I/O SchedulersLinux Kernel I/O Schedulers
Linux Kernel I/O Schedulers
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2
 

Similar to Tasklet vs work queues (Deferrable functions in linux)

Concurrent Programming in Java
Concurrent Programming in JavaConcurrent Programming in Java
Concurrent Programming in Java
Ruben Inoto Soto
 
.NET Multithreading/Multitasking
.NET Multithreading/Multitasking.NET Multithreading/Multitasking
.NET Multithreading/Multitasking
Sasha Kravchuk
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrent
Roger Xia
 
RTX Kernal
RTX KernalRTX Kernal
RTX Kernal
Team-VLSI-ITMU
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
Neeraj Kaushik
 
Performance schema and_ps_helper
Performance schema and_ps_helperPerformance schema and_ps_helper
Performance schema and_ps_helperMark Leith
 
unit5 uc.pptx
unit5 uc.pptxunit5 uc.pptx
unit5 uc.pptx
KandavelEee
 
Quick Introduction to Kotlin Coroutine for Android Dev
Quick Introduction to Kotlin Coroutine for Android DevQuick Introduction to Kotlin Coroutine for Android Dev
Quick Introduction to Kotlin Coroutine for Android Dev
Shuhei Shogen
 
Analysing in depth work manager
Analysing in depth work managerAnalysing in depth work manager
Analysing in depth work manager
lpu
 
How eBay does Automatic Outage Planning
How eBay does Automatic Outage PlanningHow eBay does Automatic Outage Planning
How eBay does Automatic Outage Planning
CA | Automic Software
 
Big data unit iv and v lecture notes qb model exam
Big data unit iv and v lecture notes   qb model examBig data unit iv and v lecture notes   qb model exam
Big data unit iv and v lecture notes qb model exam
Indhujeni
 
Free oracle performance tools
Free oracle performance toolsFree oracle performance tools
Free oracle performance tools
Rogerio Bacchi Eguchi
 
Quartz Scheduler
Quartz SchedulerQuartz Scheduler
Quartz Scheduler
Software Infrastructure
 
FreeRTOS Slides annotations.pdf
FreeRTOS Slides annotations.pdfFreeRTOS Slides annotations.pdf
FreeRTOS Slides annotations.pdf
AbdElrahmanMostafa87
 
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward
 
Oracle’ın parallel execution yetenekleri ve performans
Oracle’ın parallel execution yetenekleri ve performansOracle’ın parallel execution yetenekleri ve performans
Oracle’ın parallel execution yetenekleri ve performans
Emrah METE
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
nitin anjankar
 
Sprint 133
Sprint 133Sprint 133
Sprint 133
ManageIQ
 
Completable future
Completable futureCompletable future
Completable future
Srinivasan Raghvan
 
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docxSMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
pbilly1
 

Similar to Tasklet vs work queues (Deferrable functions in linux) (20)

Concurrent Programming in Java
Concurrent Programming in JavaConcurrent Programming in Java
Concurrent Programming in Java
 
.NET Multithreading/Multitasking
.NET Multithreading/Multitasking.NET Multithreading/Multitasking
.NET Multithreading/Multitasking
 
Java util concurrent
Java util concurrentJava util concurrent
Java util concurrent
 
RTX Kernal
RTX KernalRTX Kernal
RTX Kernal
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
 
Performance schema and_ps_helper
Performance schema and_ps_helperPerformance schema and_ps_helper
Performance schema and_ps_helper
 
unit5 uc.pptx
unit5 uc.pptxunit5 uc.pptx
unit5 uc.pptx
 
Quick Introduction to Kotlin Coroutine for Android Dev
Quick Introduction to Kotlin Coroutine for Android DevQuick Introduction to Kotlin Coroutine for Android Dev
Quick Introduction to Kotlin Coroutine for Android Dev
 
Analysing in depth work manager
Analysing in depth work managerAnalysing in depth work manager
Analysing in depth work manager
 
How eBay does Automatic Outage Planning
How eBay does Automatic Outage PlanningHow eBay does Automatic Outage Planning
How eBay does Automatic Outage Planning
 
Big data unit iv and v lecture notes qb model exam
Big data unit iv and v lecture notes   qb model examBig data unit iv and v lecture notes   qb model exam
Big data unit iv and v lecture notes qb model exam
 
Free oracle performance tools
Free oracle performance toolsFree oracle performance tools
Free oracle performance tools
 
Quartz Scheduler
Quartz SchedulerQuartz Scheduler
Quartz Scheduler
 
FreeRTOS Slides annotations.pdf
FreeRTOS Slides annotations.pdfFreeRTOS Slides annotations.pdf
FreeRTOS Slides annotations.pdf
 
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
Flink Forward SF 2017: Feng Wang & Zhijiang Wang - Runtime Improvements in Bl...
 
Oracle’ın parallel execution yetenekleri ve performans
Oracle’ın parallel execution yetenekleri ve performansOracle’ın parallel execution yetenekleri ve performans
Oracle’ın parallel execution yetenekleri ve performans
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
 
Sprint 133
Sprint 133Sprint 133
Sprint 133
 
Completable future
Completable futureCompletable future
Completable future
 
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docxSMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
 

More from RajKumar Rampelli

Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linux
RajKumar Rampelli
 
Introduction to Python - Running Notes
Introduction to Python - Running NotesIntroduction to Python - Running Notes
Introduction to Python - Running Notes
RajKumar Rampelli
 
Linux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewLinux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver Overview
RajKumar Rampelli
 
Sql injection attack
Sql injection attackSql injection attack
Sql injection attack
RajKumar Rampelli
 
Turing awards seminar
Turing awards seminarTuring awards seminar
Turing awards seminar
RajKumar Rampelli
 
Higher education importance
Higher education importanceHigher education importance
Higher education importance
RajKumar Rampelli
 
C compilation process
C compilation processC compilation process
C compilation process
RajKumar Rampelli
 

More from RajKumar Rampelli (7)

Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linux
 
Introduction to Python - Running Notes
Introduction to Python - Running NotesIntroduction to Python - Running Notes
Introduction to Python - Running Notes
 
Linux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewLinux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver Overview
 
Sql injection attack
Sql injection attackSql injection attack
Sql injection attack
 
Turing awards seminar
Turing awards seminarTuring awards seminar
Turing awards seminar
 
Higher education importance
Higher education importanceHigher education importance
Higher education importance
 
C compilation process
C compilation processC compilation process
C compilation process
 

Recently uploaded

Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 

Recently uploaded (20)

Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 

Tasklet vs work queues (Deferrable functions in linux)

  • 1. Tasklet Vs Work queues By Rajkumar Rampelli
  • 2. Outline • • • • • • Deferrable functions Top Half Vs Bottom Half Tasklet Work queue Tasklet Vs Work queue Conclusion 12/6/2013 Raj Kumar Rampelli 2
  • 3. Deferrable function • Mechanism for supporting the delayed execution of any function in Interrupt handlers (Interrupt context) • Interrupt Context – Kernel enters Interrupt context when hardware interrupt received – Kernel enters Process/Kernel context from Interrupt context after servicing the hardware interrupt – Execution of tasks in Interrupt context should be minimized • Why - Majority of Interrupts are disabled, therefore latency to handle other interrupts will be increased • Solution: Move execution of not urgent function (piece of code) into process context (Deferrable function) • Add deferrable functions in Interrupt Handlers • Deferrable functions: can be executed in process context – Tasklet – Work queues 12/6/2013 Raj Kumar Rampelli 3
  • 4. Top Half Vs Bottom Half Top Half Bottom Half Processing of tasks in Interrupt Handler (Interrupt context) Processing of tasks in Kernel context Interrupts are disabled Interrupts are not disabled Add Deferrable functions for delayed execution Handles Deferrable functions Processing time should be less -NA- Uses Tasklets and work queue APIs for deferrable mechanism 12/6/2013 Raj Kumar Rampelli 4
  • 5. Tasklet: To schedule the work (function) to run later point of time so that reducing the amount of work done in interrupt handlers. Tasklet Initialization APIs Usage void tasklet_function (unsigned long data); Deferrable function i.e. actual Task DECLARE_TASKLET (tasklet_name, tasklet_function, tasklet_data); • Initializes the tasklet structure (tasklet_struct) with passing argument list • Tasklets are enabled by default • Next step: Schedule the task DECLARE_TASKLET_DISABLED (tasklet_name, tasklet_function, tasklet_data); • Initializes the tasklet structure • Tasklets are disabled • Next step: Enable Tasklet before schedule the task void tasklet_init(struct tasklet_struct *, void (*func) (unsigned long), unsigned long data); • Initializes the tasklet structure (tasklet_struct) with passing argument list 12/6/2013 Raj Kumar Rampelli 5
  • 6. Tasklet (contd.) Tasklet Enable/Disable APIs Usage void tasklet_enable (struct tasklet_struct *); /* Enable normal priority scheduling */ void tasklet_disable (struct tasklet_struct *); /* returns after disabling the tasklet */ void tasklet_hi_enable (struct tasklet_struct *); /* Enabling High priority scheduling */ void tasklet_disable_nosync (struct tasklet_struct *); 12/6/2013 /* May returns before termination i.e. no synchronization with disabling of tasklet */ Raj Kumar Rampelli 6
  • 7. Tasklet (contd.) Tasklet Schedule APIs Usage void tasklet_schedule (struct tasklet_struct *); /* Normal priority scheduling */ void tasklet_hi_schedule (struct tasklet_struct *); /* Higher priority scheduling */ CPU maintains the normal and high priority softirq vectors lists (normal priority vector list and high priority vector list) where these functions are queued. If the function is higher priority function then it is en-queued in higher priority softirq vector list and similar case for normal priority functions. Kill a Tasklet Usage void tasklet_kill (struct tasklet_struct *); /* Kill a tasklet */ void tasklet_hi_kill (struct tasklet_struct *); /* Kill the tasklet and ensure they would never run */ 12/6/2013 Raj Kumar Rampelli 7
  • 8. Work queue • Added in linux kernel 2.6 version • Use two data structures – struct workqueue_struct • Work is queued here in Interrupt context • The same work is executed in Kernel context – struct work_struct • Identifies the work and deferrable function • Kernel threads named "events/X" will extract work from the core work queue and activates the work's handler function. Tasklet Added in linux kernel 2.3 version In 2.6 kernel version Sleep in Handler function  Not possible 12/6/2013 Work queue Possible. Latency is less Raj Kumar Rampelli More compared to Tasklet 8
  • 9. Work queue APIs Create and destroy work queue structure Usage struct workqueue_struct *create_workqueue(name); /* Creates core workqueue */ void destroy_workqueue(struct workqueue_struct *); /* Destroy the workqueue */ Initialization of work structure Usage INIT_WORK(work, function); /* Initializes the work structure with function handler */ INIT_DELAYED_WORK(work, function); /* Add any delay before adding this work INIT_DELAYED_WORK_DEFERRABLE(work, into work queue structure */ function); 12/6/2013 Raj Kumar Rampelli 9
  • 10. Work queue APIs (contd.) • Add work on to work queue – int queue_work (struct workqueue_struct *wq, struct work_struct *work); – /* specify the CPU on which the handler should run */ int queue_work_on (int cpu, struct workqueue_struct *wq, struct work_struct *work); – /* Queue specified work on to specified work queue after delay */ int queue_delayed_work (struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay); – int queue_delayed_work_on (int cpu, struct workqueue_struct *wq, struct delayed_work *work), unsigned long delay); • The below functions doesn't require workqueue structure defined. Since, they uses kernel-global work queue. So, no need to pass workqueue_struct in the argument list. – – – – 12/6/2013 int schedule_work (struct work_struct *): int schedule_work_on (int cpu, struct work_struct *): int scheduled_delayed_work (struct delayed_work *, unsigned long delay); int scheduled_delayed_work_on (int cpu, struct delayed_work *, unsigned long delay); Raj Kumar Rampelli 10
  • 11. Work queue APIs (contd.) • Cancel work /* terminate work in the queue, which is not already executing in the handler */ int cancel_work_sync (struct work_struct *); int cancel_delayed_work_sync (struct delayed_work *); • Flush work Below functions are used to flush the work and works in the specified workqueue. /* Flush a particular work and block until it is completed */ int flush_work (struct work_struct *); /* Flush all works in given workqueue and block until it is completed */ int flush_workqueue (struct workqueue_struct *); /* Flush kernel-global work queue */ void flush_scheduled_work (void); • Status of work We can use below two functions to know whether the given work is pending i.e. its handler function is not yet started. work_pending(work); delayed_work_pending (work); 12/6/2013 Raj Kumar Rampelli 11
  • 12. Conclusion • Reduce the execution time in Interrupt context by using deferrable function mechanism • Top Half: Processing of tasks in Interrupt Handler (Interrupt context) • Bottom Half: Processing of tasks in Kernel/Process context • Two type of deferrable functions – Tasklet – Work queue • Aim: To schedule the work/function (not urgent piece of code) in interrupt handler to run later point of time (in bottom half) so that reducing the amount of work done in interrupt handlers. • Tasklet and Work queue both do the above task using their own set of APIs • For more details visit: www.practicepeople.blogspot.com 12/6/2013 Raj Kumar Rampelli 12
  • 13. THANK YOU  12/6/2013 Raj Kumar Rampelli 13