logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Aryan BediComputer science
(5/5)

534 Answers

Hire Me
expert
Dayanara AliPolitical science
(5/5)

733 Answers

Hire Me
expert
Noel HaywardGeneral article writing
(5/5)

710 Answers

Hire Me
expert
Darryl HunterPsychology
(5/5)

832 Answers

Hire Me
C++ Programming

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

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS


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:

  • You can safely assume that the input files will always be in the proper format.
  • You must use POSIX threads. A penalty of 100% will be applied to submissions using a thread library other than pthread.
  • You cannot use pthread_join or sleep to achieve thread synchronization. A penalty of 100% will be applied to submissions using the previous system calls to synchronize the child threads.
  • The main thread must create the child threads based on the order of the Elias-Gamma codes in the input file (not based on the positions of the characters in original file).

 

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme