PDC Notes. 2.
PDC Notes. 2.
Parallelism ek technique hai jo computational efficiency badhane ke liye use hoti hai. Isme ek
bada problem chhoti sub-problems me divide hota hai, jo ek saath (simultaneously) solve kiye ja
sakte hain. Parallelism ke do main types hote hain: Data Parallelism aur Control Parallelism. Ab
in dono ko detail me samjhte hain:
Data parallelism tab hota hai jab ek hi operation ko multiple processors par alag-alag data sets
par ek saath execute kiya jata hai. Matlab, ek bada data set ko chhoti-chhoti parts me divide
karke har processor ko ek part diya jata hai, jisme wo same operation apply karta hai.
Example:
Agar ek 4x4 matrix ko process karna hai aur 4 processors available hain, to har processor ek
row ko handle karega. Sabhi rows par ek saath (simultaneously) computation hoga, aur last me
sab results ko combine kiya jayega. Is tarike se computation fast ho jata hai.
Ek aur Example:
Maan lo ki ek bahut bada image file hai jisme brightness adjust karni hai. Agar hum us image ko 4
parts me divide kar dein aur har processor apne assigned part par brightness adjustment kare, to
pura process fast ho jayega.
Control parallelism tab hota hai jab alag-alag tasks ko ek saath alag processors par execute kiya
jata hai. Matlab, ek processor ek task karega, doosra processor doosra task karega, aur teek isi
tarah sab apna-apna kaam parallelly karenge. Ye ek pipeline structure jaisa hota hai, jisme ek
processor ka output doosre processor ke input me chala jata hai.
Example:
Agar ek image processing system me ek image ko process karna hai, to:
• Processor 1 edge detection karega,
• Processor 2 image smoothing karega,
• Processor 3 color correction karega.
Teeno ka kaam ek saath (simultaneously) hoga, is wajah se pura process fast hoga.
Ek aur Example:
Maan lo ek factory me mobile phones assemble ho rahe hain.
• Processor 1 motherboard lagata hai,
• Processor 2 battery fix karta hai,
• Processor 3 screen attach karta hai.
Agar ye saari cheeze sequentially (ek ke baad ek) hoti to time zyada lagta, lekin
parallel processing ke wajah se assembly fast hoti hai.
Summary (Saar)
1. Data Parallelism → Same kaam, alag-alag data par ek saath. (e.g., Matrix
processing, Image Brightness adjustment)
2. Control Parallelism → Alag-alag kaam, ek saath execute. (e.g., Image
processing pipeline, Mobile assembly)
Dono techniques ka use computational efficiency badhane ke liye hota hai, aur har
tarah ke applications ke hisaab se inhe implement kiya jata hai.
Amdahl’s Law ek rule hai jo batata hai ki kisi task ka execution speed kitna improve ho sakta
hai agar hum multiple processors ka use karein.
Jab hum kisi task ko parallel banate hain, tab bhi uska kuch part sequential (ek ek step me
hone wala) hota hai. Amdahl’s Law ye batata hai ki agar task ka koi part parallel nahi ho sakta,
to chahe hum jitne bhi processors laga lein, performance ek limit tak hi badh sakti hai.
Conclusion
Amdahl’s Law ye samjhata hai ki jitna task parallel ho sakta hai, utna hi speedup milega, lekin
agar task ka kuch part sequential hai, to speedup ek limit tak hi jayega.
Isliye parallel computing me optimization karne se pehle sequential bottlenecks ko hatana
zaroori hai!
Parallel computing ka main concept hai ki ek task ko multiple processors par tod kar
simultaneously execute kiya jaye, taaki speed aur efficiency badh sake.
Parallel processors ka organization kaafi important hota hai, aur ye do tarah se classify kiya jata
hai:
1. Static Interconnections
• Fixed aur predefined connections hote hain, jo execution ke dauraan
change nahi hote.
• Examples:
• Bus-based systems (sabhi processors ek common bus share karte
hain)
• Crossbar switches (multiple processors aur memory modules directly
interconnected hote hain)
• Multistage Interconnection Networks (MINs) (hierarchical switching
network)
2. Dynamic Interconnections
• Ye flexible hote hain, aur execution ke dauraan reconfigure ho sakte
hain.
• Examples:
• Packet-switched networks (data packets routers ke through bheje jate
hain)
• Switch-based networks (network switching mechanism use hota hai)
• Dynamically adjustable paths (network dynamically change hota hai,
jisse flexibility badhti hai)
Parallel processors ko instruction aur data streams ke base par classify kiya jata hai:
1. SISD (Single Instruction, Single Data)
• Ek hi instruction ek data set pe apply hota hai (traditional processors,
like normal PCs).
2. SIMD (Single Instruction, Multiple Data)
• Ek hi instruction multiple data streams par apply hota hai (like GPUs).
3. MISD (Multiple Instruction, Single Data)
• Multiple instructions ek hi data pe apply hote hain (rarely used).
4. MIMD (Multiple Instruction, Multiple Data)
• Alag-alag processors alag-alag instructions alag-alag data pe apply
karte hain (modern supercomputers me use hota hai).
Parallel systems me processors aur memory ka interconnection kaafi important hota hai. Kuch
common topologies:
1. Bus-Based
• Sabhi processors ek common bus share karte hain.
2. Ring
• Processors ek circular structure me connected hote hain.
3. Mesh
• Processors grid format me hote hain, jisme har node kisi aur ke sath
connected hoti hai.
4. Hypercube
• Multi-dimensional cube structure, jo fast communication provide
karta hai.
5. Tree
• Hierarchical structure hota hai, jo broadcasting ke liye achha hota hai.
Shared memory system me sabhi processors ek global memory access kar sakte hain.
Iske do main types hote hain:
1. UMA (Uniform Memory Access)
• Sabhi processors memory ko equal latency ke sath access kar sakte
hain.
2. NUMA (Non-Uniform Memory Access)
• Memory different latencies pe access hoti hai, jo system ke structure
pe depend karta hai.
Advantages:
• Fast communication
• Simple programming
Disadvantages:
• Memory contention (ek time pe zyada processors agar same memory ko
access karein, to bottleneck ho sakta hai)
• Synchronization overhead (data consistency maintain karna mushkil hota hai)
Distributed memory architecture me har processor ka apna local memory hota hai, aur
processors ek network ke through communicate karte hain.
Key Features:
• Koi shared global memory nahi hoti
• Scalable architecture, jo large systems ke liye suitable hota hai
Advantages:
• No memory contention (kyunki har processor apni memory use karta hai)
Disadvantages:
• Complex programming
• Higher latency (kyunki message passing me time lagta hai)
Conclusion
Parallel processors computing me speed aur efficiency improve karne ke liye use hote hain.
Flynn’s Taxonomy ke basis pe systems ko classify kiya jata hai, aur interconnections ka structure
performance pe depend karta hai. Shared aur distributed memory systems dono ke apne
advantages aur disadvantages hote hain, aur system design ke according suitable architecture
select karna important hota hai.
Parallel Computing ka main concept hai ki ek bada task ko chhoti independent tasks me tod kar
multiple processors pe execute karna, jisse computation time kam ho jaye.
Matrix multiplication ek important operation hai jo scientific computing aur machine learning
me use hota hai. Isko parallel computing me efficiently implement kiya jata hai.
Basic Idea
• Agar A (m × n matrix) aur B (n × p matrix) diye gaye hain, to result C (m × p
matrix) hoga.
• Parallel computing me C matrix ka computation multiple processors me
distribute kiya jata hai.
Challenges:
• Load balancing (Har processor ke paas equal kaam ho)
• Communication overhead (Data transfer minimize ho)
• Scalability (Processors badhne par bhi performance efficient rahe)
Parallel Computing me large datasets ko efficiently sort karna ek bada challenge hota hai. Iske
liye parallel sorting algorithms ka use hota hai.
Searching kaafi common operation hai large-scale systems me. Parallel algorithms searching
ko efficient aur fast banate hain.
Conclusion
Parallel algorithms speed aur efficiency improve karne ke liye use hote hain.
• Matrix multiplication ke liye Cannon’s, Fox’s aur Strassen’s algorithms use
kiye jate hain.
• Sorting me Parallel Merge Sort, Bitonic Sort, Odd-Even Transposition Sort
aur Sample Sort important hote hain.
• Searching ke liye Parallel Binary Search, Hash-Based Searching, BFS aur
DFS efficient solutions hain.
Leader Election and Mutual Exclusion in Distributed Systems – Simple Explanation in Hinglish
Distributed Systems me Leader Election aur Mutual Exclusion bahut important concepts hain,
jo multiple nodes ya processes ke coordination aur synchronization ke liye zaroori hote hain.
1. Leader Election
Leader Election ka main goal hai ek system me ek single process ya node ko “leader” elect
karna, jo baaki sabko coordinate karega.
Leader Election kyun zaroori hai?
• Coordination: Leader resources manage karta hai aur nodes ke actions
synchronize karta hai.
• Fault Tolerance: Agar leader fail ho jaye, to naya leader elect karna padta
hai taaki system smoothly chale.
• Consistency: Leader ensure karta hai ki sabhi nodes ka state same ho, jisse
data aur actions consistent rahein.
Mutual Exclusion ka matlab hai ki ek time pe sirf ek process critical section (CS) me enter
kare, jisse race conditions aur conflicts avoid ho sakein.
Applications:
• Distributed file locking
• Cloud computing me shared resources manage karna
• Replicated databases me consistency maintain karna
Distributed Systems me Scheduling aur Load Balancing bahut important concepts hain, jo
tasks ko efficiently distribute karne aur execution optimize karne ke liye use hote hain.
Types of Scheduling:
1. Static Scheduling
• Task allocation execution se pehle decide hoti hai.
• Pure system ke resources aur tasks ka knowledge pehle se hona
chahiye.
• Example: Grid computing me task allocation.
2. Dynamic Scheduling
• Task allocation runtime pe decide hoti hai.
• Agar workload unpredictable ho to ye approach useful hoti hai.
• Example: Cloud computing me load balancing.
Load Balancing ka main goal hai ki sabhi nodes ya processors pe workload evenly
distribute ho, taaki koi bhi single node overload na ho aur system fast chale.
A) Scheduling Algorithms
1. Round Robin Algorithm
• Tasks ko circular order me assign kiya jata hai.
• Simple aur easy to implement hai.
• Task size agar alag-alag ho, to imbalance ho sakta hai.
2. Least Loaded Algorithm
• Jis node pe sabse kam load hai, usko task assign hota hai.
• Real-time load monitoring ka use karta hai.
3. First Come, First Serve (FCFS) Algorithm
• Jo task pehle aaya, wo pehle execute hoga.
• Simple aur easy to implement hai.
• Load balancing optimize nahi hota.
Conclusion
• Scheduling aur Load Balancing ka main goal hota hai system ka
performance optimize karna, execution fast karna aur resources ka efficient use
karna.
• Static Scheduling aur Load Balancing predefined hota hai, jabki Dynamic
approaches runtime pe adapt karte hain.
• Load balancing ke liye Round Robin, Least Loaded, Weighted Fair
Scheduling aur ACO jaise algorithms use hote hain.
• Scalability, Fault Tolerance aur Security scheduling aur load balancing ke
major challenges hain.