This assignment will introduce you to synchronization mechanisms in UNIX using POSIX threads.
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:
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:
The expected output is:
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'
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