forked from jakaspeh/concurrency
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathompSection.cpp
More file actions
40 lines (32 loc) · 712 Bytes
/
ompSection.cpp
File metadata and controls
40 lines (32 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <chrono>
#include <thread>
#include <omp.h>
void function_1()
{
for (int i = 0; i != 3; i++)
{
std::cout << "Function 1 (i = " << i << ")" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
void function_2()
{
for (int j = 0; j != 4; j++)
{
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout << " Function 2 "
<< "(j = " << j << ")" << std::endl;
}
}
int main()
{
#pragma omp parallel sections
{
#pragma omp section
function_1();
#pragma omp section
function_2();
}
return 0;
}