5.5.9 · D1 · HinglishEmbedded Systems & Real-Time Software

FoundationsRTOS concepts — task, scheduler, preemption, context switch

2,310 words11 min read↑ Read in English

5.5.9 · D1 · Coding › Embedded Systems & Real-Time Software › RTOS concepts — task, scheduler, preemption, context switch

Parent note RTOS Concepts ko fluently padhne se pehle, tumhe wo har word aur symbol khud se pata hona chahiye jo wo assume karta hai. Ye page un sab ko, ground se, ek aisi order mein build karta hai jahan har idea sirf pehle wale ideas pe lean karta hai.


0. CPU: ek worker, ek desk

Figure — RTOS concepts — task, scheduler, preemption, context switch

Jo kuch bhi ek RTOS karta hai wo is ek worker ko kai saare manuals ke beech share karne ka ek clever tarika hai.


1. Registers — worker ke held slips of paper

Parent note kuch specific registers ka naam leta hai. Har ek, simple words mein:


2. RAM aur stack — private notepad

Figure — RTOS concepts — task, scheduler, preemption, context switch

Har RTOS task ko apna khud ka stack milta hai — apna private pile of plates — isliye parent kehta hai ki task ka "apna stack hai." Zyada padhne ke liye Stack memory and TCB dekhein.


3. Super-loop — RTOS se pehle ki zindagi

Ye "ek slow job sabko freeze kar deta hai" problem woh villain hai jise poora RTOS topic defeat karta hai.


4. Interrupts aur tick — kandhe par ek thapki


5. Frequency, period, aur symbols , , Hz, µs

Parent ke formulas inhe use karte hain; ye raha zero se.


6. Priority aur states — manager ka board

Figure — RTOS concepts — task, scheduler, preemption, context switch

7. TCB — har task ke liye ek index card


Ye foundations topic ko kaise feed karte hain

CPU one worker one stream

Registers PC SP r0-r12

Stack push and pop

TCB saved stack pointer

Super-loop the old way

Interrupts and ISR

Tick the heartbeat

Scheduler picks next task

Priority and states

Frequency and period f and T

Overhead formula

Context switch

Why an RTOS exists

Map ko top-down padhein: registers aur stack, TCB aur context switch banate hain; interrupts aur tick, scheduler ko drive karte hain; frequency, overhead maths ko feed karta hai — aur ye sab kyun ek RTOS exist karta hai pe land karta hai.


Equipment checklist

Recall Self-test: kya tum parent note kholne se pehle har ek ka jawab de sakte ho?

Ek CPU core ek waqt mein kitne instruction streams run karta hai? ::: Exactly ek. Register kya hai, ek phrase mein? ::: CPU ke andar ek tiny fast storage slot jo abhi use ho rahi value hold karta hai. PC (program counter) kya hold karta hai? ::: Current instruction ka address — "main kaun si line pe hoon". SP (stack pointer) kya mark karta hai? ::: Task ki private stack ka top (uska pile of plates). Stack items kaise add aur remove karta hai? ::: Top pe push, top se pop — last-in, first-out. Interrupt kya hai? ::: Ek hardware signal jo CPU ko pause karke kuch abhi handle karne pe majboor karta hai. Tick kya hai? ::: Ek regular timer interrupt — RTOS ki heartbeat jo scheduler ko jagati hai. ko period mein convert karo. ::: . Ek second mein kitne microseconds hote hain? ::: Ek million (). Chaar task states ke naam batao. ::: Running, Ready, Blocked, Suspended. "Blocked" system ki help kyun karta hai? ::: Ek Blocked task CPU release kar deta hai taki doosre tasks run ho sakein. TCB mein kaun sa single value kisi task ki poori saved state ka handle hai? ::: Uska saved stack pointer (SP). Ek super-loop mein, agar ek job 50 ms wait karti hai toh kya hota hai? ::: Us ke peeche ki har job us 50 ms ke liye stall ho jaati hai.