Skip to content

nicolettecelli/Multithreading

Repository files navigation

Multithreaded Programming and Synchronization

Operating Systems Assignment 3

Part 1: Simple Multithreaded Programming Using Pthreads

Task 1.1: Without Synchronization

  • Compile with gcc -pthread task1-1.c -o task1-1'
  • Run with ./task1-1 <threadcount>

The results of tests using 1, 2, 5, 10, and 50 threads are found in the test1-1\ directory.

Task 1.2: With Proper Synchronization

  • Compile with gcc -pthread -D PTHREAD_SYNC task1-2.c -o task1-2
  • Run with ./task1-2 <number_of_threads>

The results of tests using 1, 2, 5, 10, and 100 threads are found in the test1-2\ directory.

Task 1.3: Queue Scheduling

  • Compile with gcc -pthread task1-3.c -o task1-3
  • Run with ./task1-3 <number_of_students> <office_capacity>

Part 2: Multithreaded/Parallel Programming Using OpenMP

For the following tasks, the number of threads can be changed using export OMP_NUM_THREADS=<number>.

Task 2.1: Hello World

Task 2.1 is found in the OpenMP/ directory.

  • Compile with gcc -fopenmp helloworld.c -o helloworld
  • Run with ./helloworld

Task 2.2: Work Sharing

  • Compile with gcc -fopenmp task2-2.c -o task2-2
  • Run with ./task2-2

The results using dynamic scheduling are located in 2-2results_dynamic.txt.
The results using static scheduling are located in 2-2results_static.txt.

Task 2.3: Work Sharing with Sections Construction

  • Compile with gcc -fopenmp task2-3.c -o task2-3
  • Run with ./task2-3

The output is recorded in 2-3results.txt.

Task 2.4: Parallelizing Matrix Multiplication

Change the values of N and M in the code (lines 19 and 20) to change the size of the matrix.
Change the value of omp_set_num_threads() in the code (line 24) to change the number of threads.

This program includes separate labelled blocks of code for each parallelization method. Comment out the unnecessary methods to test each method.

  • Compile with gcc -fopenmp task2-4.c -o task2-4
  • Run with ./task2-4

Part 3: OpenMP Solution for the Queue Scheduling Problem in Task 1.3

  • Compile with gcc -fopenmp part3.c -o part3
  • Run with ./part3 <number_of_students> <office_capacity>

About

Operating Systems Assignment 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages