Semaphores, mutexes, events, critical sections in WinAPI
Task:
- Develop a parallel algorithm for solving a mathematical problem
MU = MD * MC * d + max (Z) * MRusingWinAPIlibrary inC++; - Identify shared resources;
- Describe the algorithm of each thread (T1 - Ti) with the definition of critical areas and synchronization points (Wij, Sij);
- Develop the structural scheme of interaction of threads where to apply all specified means of interaction of processes;
- Develop a program;
- Perform program debugging;
- Get the correct calculation results;
- Use Windows Task Manager to monitor CPU kernel load.
Means of organizing interaction: semaphores, mutexes, critical sections, events;
Means of interaction: semaphores.
Symbols in the block diagram:
CS- to access the shared resourced,m;M- to access the shared resourceMC;E1- for synchronization with the completion of input inT1;E3- for synchronization with the completion of input inT3;E4- for synchronization with the completion of input inT4;Sm1,Sm2,Sm3,Smax- to synchronize the calculations of the maximumZ;S.MA1,S.MA2,S.MA3- to synchronize the rest of the calculations and output the result.
Semaphores, mutexes, events, critical sections in WinAPI
Task:
- Develop a parallel algorithm for solving a mathematical problem
Z = sort(D * (ME * MM)) + (B * C) * E * xinC#; - Identify shared resources;
- Describe the algorithm of each thread (T1 - Ti) with the definition of critical areas and synchronization points (Wij, Sij);
- Develop the structural scheme of interaction of threads where to apply all specified means of interaction of processes;
- Develop a program;
- Perform program debugging;
- Get the correct calculation results;
- Use Windows Task Manager to monitor CPU kernel load.
Problem: Z = sort (D * (ME * MM)) + (B * C) * E * x;
Programming language: C#;
Means of organizing interaction: semaphores, mutexes, events, critical sections, atomic variables (types);
Symbols in the block diagram:
M- mutex for access to the shared resourceb;volatile- keyword to access the shared resourcex;Lock- lock to access the shared resourceD;ME- semaphore for access to the shared resourceME;E0- event for synchronization with the completion of input inT1;E1- event for synchronization with the completion of input inT2;E2- event for synchronization with the completion of input inT3;E3- event for synchronization with the completion of input inT4;S0- semaphore for synchronization with the completion of the mergerKin the threadT1;S1- semaphore to synchronize the completion of calculationsZHin the threadT2;S2- semaphore to synchronize the completion of calculationsZHin the threadT3;S3- semaphore to synchronize the completion of calculationsZHin the threadT4;SM0- semaphore to synchronize the completion of theK2Hmerger in the threadT2;SM1- semaphore to synchronize the completion of sortingKHin the threadT3;SM2- semaphore to synchronize the completion of sortingKHin the threadT4.
Java. Monitors
Task:
- Develop a parallel algorithm for solving a mathematical problem
E = (B * MR) * (MM * MO) + min(B) * Q * dusing monitors inJava; - Identify shared resources;
- Describe the algorithm of each thread (T1 - Ti) with the definition of critical areas and synchronization points (Wij, Sij);
- Develop the structural scheme of interaction of threads where to apply all specified means of interaction of processes;
- Develop a program;
- Perform program debugging;
- Get the correct calculation results;
- Use Windows Task Manager to monitor CPU kernel load.
Problem: E = (B * MR) * (MM * MO) + min(B) * Q * d;
Programming language: Java;
Means of organizing interaction: Java monitors, synchronized blocks;
Symbols in the block diagram:
InputSignal- signal about the completion of input in threadsT1,T2,T3;WaitForInput- waiting for input completion signals in threadsT1,T2,T3;Signal- signal about the end of calculationEin threadsT2,T3,T4;WaitForSignal- waiting for signals to complete the calculation ofEin threadsT2,T2,T3;SignalCalcM- signal about the completion of complete the calculation ofmin threadsT1,T2,T3,T4;WaitForCalcM- waiting for signals to complete the calculation ofmin threadsT1,T2,T3,T4;SignalCalcA- signal about the completion of complete the calculation ofAнin threadsT1,T2,T3,T4;WaitForCalcA- waiting for signals to complete the calculation ofAнin threadsT1,T2,T3,T4;copyM- copying a shared resourcemby threadsT1,T2,T3,T4;calcM- calculation ofm = min[m, m(i)]by threadsT1,T2,T3,T4;copyA- copying a shared resourceAby threadsT1,T2,T3,T4;calcA- calculationAн;copyD- copying a shared resourcedby threadsT1,T2,T3,T4;setD- input of the shared resourcedby threadT3;copyB- copying a shared resourceBby threadsT1,T2,T3,T4;setB- input of the shared resourceBby threadT2;copyMO- copying a shared resourceMOby threadsT1,T2,T3,T4;setMO- input of the shared resourceMOby threadT3;
OpenMP. Barriers, critical sections.
Task:
- Develop a parallel algorithm for solving a mathematical problem
Z = (B * C) * D + E * (MA * MB) * xusing the OpenMP library in C ++; - Identify shared resources;
- Describe the algorithm of each thread (T1 - Ti) with the definition of critical areas and barriers; (
- Develop the structural scheme of interaction of threads where to apply all specified means of interaction of processes;
- Develop a program;
- Perform program debugging;
- Get the correct calculation results;
- Use Windows Task Manager to monitor CPU kernel load.
Problem: Z = (B * C) * D + E * (MA * MB) * x;
Programming language: C++;
Means of organizing interaction: barriers, locks, critical sections of OpenMP;;
ADA. Rendezvous.
Task:
- Develop a parallel algorithm for solving a mathematical problem
Z = (B * C) * D + E * (MA * MB) * xusing the rendezvous mechanism in ADA; - Describe the algorithm of each thread;
- Develop the structural scheme of interaction of threads where to apply all specified means of interaction of processes;
- Develop a program, Perform program debugging, Get the correct calculation results;
Problem: Z = (B * C) * D + E * (MA * MB) * x;
Programming language: ADA;
Means of organizing interaction: rendezvous;
The structure of PKS LP: linear.




