-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
45 lines (38 loc) · 1.16 KB
/
main.cpp
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
39
40
41
42
43
44
#include <cstdio>
#include <vector>
#include <unistd.h>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <pthread.h>
#include "processes.h"
#include "threads.h"
using namespace std;
int main(int argc, char** argv) {
printf("Main process is created. (pid: %d)\n", getpid());
int num_processes = 0;
int num_threads = 0;
vector<string> class_name;
class_name.push_back("os");
class_name.push_back("architecture");
class_name.push_back("java");
class_name.push_back("algorithm");
class_name.push_back("digital-design");
// Check the argument and print error message if the argument is wrong
if(argc == 3 && (atoi(argv[1]) > 0 && atoi(argv[2]) > 0))
{
num_processes = atoi(argv[1]);
num_threads = atoi(argv[2]);
// Create the child processes and sort
create_processes_and_sort(class_name, num_processes, num_threads);
}
else
{
printf("[ERROR] Expecting 2 arguments with integral value greater than zero.\n");
printf("[USAGE] %s <number of processes> <number of threads>\n", argv[0]);
}
printf("Main process is terminated. (pid: %d)\n", getpid());
return 0;
}