This assignment will introduce you to synchronization mechanisms in UNIX using POSIX threads.
Specifications:
You must write a program to implement a multithreaded version of the Elias-Gamma decoding algorithm
Your program should read its input from stdin (C++ cin) and use input redirection. The user will execute this program using I/O redirection:
./exec_filename < input_filename
where exec_filename is the name of your executable file, and input_filename is the name of the file with the integer values to encode. The format of the input file:
eliasgammacode1 pos1
eliasgammacode2 pos2
. .
eliasgammacoden posn
Where eliasgammacode is the encoded representation of the ASCII value (as an integer) of the character in the original file, and pos is the position of this character in the original file. The Elias-Gamma codes in the input file are sorted in ascending order by their ASCII value (using the position in the file in ascending order as the tie-breaker condition if the frequency of a character in the original file is greater than one).
Your program must create a child thread per Elias-Gamma code in the input file. Each child thread will decode the Elias-Gamma code assigned by the main thread, and print the ASCII representation (character) of the integer value represented by the Elias-Gamma code. You must use the synchronization mechanisms discussed in class to guarantee that the child threads will print the characters in order based on the position of the character in the original file.
Given the following input file:
0001010 9
00000100000 4
00000110000 8
00000110011 5
00000110011 6
00000110110 7
0000001000011 0
0000001000011 3
0000001001111 1
0000001010011 2
The expected output is:
COSC 3360
2nd Test:
Input File:
0001010 11
00000100000 6
00000110000 8
00000110000 10
00000110010 7
00000110010 9
0000001000101 4
0000001001101 2
0000001001101 3
0000001010010 5
0000001010011 0
0000001010101 1
CORRECT OUTPUT:
SUMMER 2020
After sorting the contents of the input file based on the position of the characters in the file, we have:
0000001000011 0 // integer = 67, ASCII = 'C'
0000001001111 1 // integer = 79, ASCII = 'O'
0000001010011 2 // integer = 83, ASCII = 'S'
0000001000011 3 // integer = 67, ASCII = 'C'
00000100000 4 // integer = 32, ASCII = ' '
00000110011 5 // integer = 51, ASCII = '3'
00000110011 6 // integer = 51, ASCII = '3'
00000110110 7 // integer = 54, ASCII = '6'
00000110000 8 // integer = 48, ASCII = '0'
0001010 9 // integer = 10, ASCII = 'n'
Notes:
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of