Objective: This project will introduce you to interprocess synchronization mechanisms in UNIX using named POSIX semaphores, pthread mutex semaphores, and pthread condition variables. You will: Use named POSIX semaphores to synchronize the producer and consumer threads. Use pthread mutex semaphores and pthread condition variables to synchronize the access to a shared buffer between producer and consumer threads. Create a fixed-sized buffer to store the encoded data generated by the producer thread. Use the buffer to store the encoded data generated by the producer thread and transfer it to the consumer thread through the shared buffer. The producer thread should read the input file and generate the Huffman code for the input data. The producer thread should then encode the input data using the Huffman code and write the encoded data to the fixed-sized buffer. The consumer thread should read the encoded data from the shared buffer and decode it using the Huffman code. The consumer thread should then write the decoded data to an output file. Problem: For this project you will modify your solution for project 1 to comply with the restrictions explained below. Given the information about the alphabet and the compressed file as input from STDIN, you need to implement a multithreaded Huffman decompressor based on the following steps: Read the input from STDIN (the Moodle server will implement input redirection to send the information from a file to STDIN). The input has the following format: 4 A3 C3 B1 D2 11 1 3 5 0024 101 6 8 100 7 The first line has a single integer value representing the number of symbols in the alphabet (n). The next n lines present the information about the alphabet. Each line presents the information about a symbol from the alphabet: A character representing the symbol. An integer representing the frequency of the symbol. The final n lines present the information about the compressed file. Each line presents the information about a compressed symbol: A string representing the binary code of the symbol. A list of m integers (where m is the frequency of the symbol) representing the positions where the symbol appears in the message. Generate the Huffman Tree based on the input. Create n POSIX threads (where n is the number of symbols in the alphabet). Each child thread executes the following tasks: Receives the Huffman tree and the information about the symbol to decompress (binary code and list of positions) from the main thread. Uses the Huffman tree to determine the character from the original message based on the binary code. Stores the decompressed character (as many times as needed based on the list of positions) on a memory location accessible by the main thread. Print the information about the assigned symbol using the output message from the example below. Print the original message. Given the previous input, the expected output is: Symbol: A, Frequency: 3, Code: 11 Symbol: C, Frequency: 3, Code: 0 Symbol: D, Frequency: 2, Code: 101 Symbol: B, Frequency: 1, Code: 100 Original message: CACACADBD Here are some important notes to consider while implementing the program: The input files will always be properly formatted. Global variables are not allowed. The critical sections must follow the guidelines discussed in class. Only named POSIX semaphores, pthreads mutex semaphores, or pthreads condition variables can be used for synchronization. pthread_join or sleep cannot be used for synchronization. The parent thread must wait for all child threads to end using pthread_join before ending its execution. The same memory address must be used to pass information from the parent thread to the child threads. The output statement format should follow the example given in the prompt project 1 code: https://replit.com/@jacksmith-2023/PA1

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Topic Video
Question

Objective:

This project will introduce you to interprocess synchronization mechanisms in UNIX using named POSIX semaphores, pthread mutex semaphores, and pthread condition variables.

You will:
Use named POSIX semaphores to synchronize the producer and consumer threads.

Use pthread mutex semaphores and pthread condition variables to synchronize the access to a shared buffer between producer and consumer threads.

Create a fixed-sized buffer to store the encoded data generated by the producer thread.

Use the buffer to store the encoded data generated by the producer thread and transfer it to the consumer thread through the shared buffer.

The producer thread should read the input file and generate the Huffman code for the input data. The producer thread should then encode the input data using the Huffman code and write the encoded data to the fixed-sized buffer.

The consumer thread should read the encoded data from the shared buffer and decode it using the Huffman code. The consumer thread should then write the decoded data to an output file.

Problem:

For this project you will modify your solution for project 1 to comply with the restrictions explained below.

Given the information about the alphabet and the compressed file as input from STDIN, you need to implement a multithreaded Huffman decompressor based on the following steps:

Read the input from STDIN (the Moodle server will implement input redirection to send the information from a file to STDIN). The input has the following format:

4

A3

C3

B1

D2

11 1 3 5

0024

101 6 8

100 7

The first line has a single integer value representing the number of symbols in the alphabet (n).

The next n lines present the information about the alphabet. Each line presents the information about a symbol from the alphabet:

A character representing the symbol.
An integer representing the frequency of the symbol.

The final n lines present the information about the compressed file. Each line presents the information about a compressed symbol:

A string representing the binary code of the symbol.

A list of m integers (where m is the frequency of the symbol) representing the positions where the symbol appears in the message.

Generate the Huffman Tree based on the input.

Create n POSIX threads (where n is the number of symbols in the alphabet). Each child thread executes the following tasks:

Receives the Huffman tree and the information about the symbol to decompress (binary code and list of positions) from the main thread.

Uses the Huffman tree to determine the character from the original message based on the binary code.

Stores the decompressed character (as many times as needed based on the list of positions) on a memory location accessible by the main thread.

Print the information about the assigned symbol using the output message from the example below.

Print the original message.

Given the previous input, the expected output is:
Symbol: A, Frequency: 3, Code: 11
Symbol: C, Frequency: 3, Code: 0
Symbol: D, Frequency: 2, Code: 101
Symbol: B, Frequency: 1, Code: 100
Original message: CACACADBD

Here are some important notes to consider while implementing the program: The input files will always be properly formatted.
Global variables are not allowed.
The critical sections must follow the guidelines discussed in class.

Only named POSIX semaphores, pthreads mutex semaphores, or pthreads condition variables can be used for synchronization. pthread_join or sleep cannot be used for synchronization.

The parent thread must wait for all child threads to end using pthread_join before ending its execution.

The same memory address must be used to pass information from the parent thread to the child threads.

The output statement format should follow the example given in the prompt

project 1 code:

https://replit.com/@jacksmith-2023/PA1

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY