Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Objective: This assignment will introduce you to interprocess synchronization mechanisms in UNIX using named POSIX semaphores, pthread mutex semaphores, and pthread condition variables

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

Computer Science

Objective:
This assignment will introduce you to interprocess synchronization mechanisms in
UNIX using named POSIX semaphores, pthread mutex semaphores, and pthread
condition variables.
Problem:
Given an alphabet (where each symbol is represented by a character and a decimal value with
the code of the symbol), you need to implement a fixed-length code decompressor based on
the following steps:
1.Read the contents of the input file using input redirection (STDIN). The format of the input
file is as follows:
- An integer value representing the number of symbols in the alphabet
- n lines (where n is the number of symbols in the alphabet) with a char representing
the value of the symbol and an integer value representing the symbol's code (in
decimal notation).
- A string representing the compressed message (sequence of bits).
Given the previous format, the following file represents a valid input file:
3
a 2
b 4
c 5
010010010100101101101
2.Calculate the number of bits of the fixed-length codes based on the value of the greatest
base 10 code in the alphabet. For decimal values greater than zero, you can use the following
formula to calculate the number of bits of the fixed-length codes: ceiling
(log_2(greatest_base_10_code_in_the_alphabet +1))
3.Create n child threads (where n is the number of symbols in the alphabet). Each child
thread executes the following tasks:
- Determines the binary representation of the symbol's code.
- Determines the frequency of the symbol in the compressed message.
- Print the character, binary code, and frequency of the assigned symbol.
4.Create m child processes or threads (where m is the number of characters in the
decompressed message) to determine each character of the decompressed message.
5.Print the decompressed message.
Given the expected input, the expected output is:
Alphabet:
Character: a, Code: 010, Frequency: 3
Character: b, Code: 100, Frequency: 1
Character: c, Code: 101, Frequency: 3
Decompressed message: aaabccc
NOTES:
• You can safely assume that the input files will always be in the proper format.
• You cannot use global variables. A 100% penalty will be applied to submissions
using global variables.
• You must define the critical sections following the guidelines.
• You must use POSIX threads. A penalty of 100% will be applied to submissions
using a thread library other than the pthread library.
• You can only use named POSIX semaphores, pthreads mutex semaphores, or
pthreads condition variables to achieve synchronization. Using pthread_join or
sleep to synchronize your threads is not allowed. A penalty of 100% will be applied
to submissions using the previous system calls to synchronize the child threads.
• You cannot use different memory addresses to pass the information from the
parent thread to the child threads.
• You must use the output statement format based on the example above.
Test Case 1
STDIN:
3
a 2
b 4
c 5
010010010100101101101
CORRECT OUTPUT:
Alphabet:
Character: a, Code: 010, Frequency: 3
Character: b, Code: 100, Frequency: 1
Character: c, Code: 101, Frequency: 3
Decompressed message: aaabccc
Test Case 2
STDIN:
13
C 0
O 1
S 2
3
3 4
6 5
0 6
P 7
R 8
I 9
N 10
G 11
2 12
000000010010000000110100010001010110001100100111100010011010101100111100011011001100
CORRECT OUTPUT:
Alphabet:
Character: C, Code: 0000, Frequency: 2
Character: O, Code: 0001, Frequency: 1
Character: S, Code: 0010, Frequency: 2
Character: , Code: 0011, Frequency: 3
Character: 3, Code: 0100, Frequency: 2
Character: 6, Code: 0101, Frequency: 1
Character: 0, Code: 0110, Frequency: 2
Character: P, Code: 0111, Frequency: 1
Character: R, Code: 1000, Frequency: 1
Character: I, Code: 1001, Frequency: 1
Character: N, Code: 1010, Frequency: 1
Character: G, Code: 1011, Frequency: 1
Character: 2, Code: 1100, Frequency: 3
Decompressed message: COSC 3360 SPRING 2022
Test Case 3
STDIN:
15
D 68
R 82
. 46
32
I 73
N 78
C 67
O 79
S 83
A 65
Y 89
: 58
U 85
L 76
E 69
1000100101001001011100100000101001010010011001110100001110011111001110010000010100111000001101100
110100110111010010000010011111010011010000010100101010101100110010001011010011
CORRECT OUTPUT:
Alphabet:
Character: D, Code: 1000100, Frequency: 1
Character: R, Code: 1010010, Frequency: 3
Character: ., Code: 0101110, Frequency: 1
Character: , Code: 0100000, Frequency: 4
Character: I, Code: 1001001, Frequency: 1
Character: N, Code: 1001110, Frequency: 2
Character: C, Code: 1000011, Frequency: 1
Character: O, Code: 1001111, Frequency: 2
Character: S, Code: 1010011, Frequency: 4
Character: A, Code: 1000001, Frequency: 1
Character: Y, Code: 1011001, Frequency: 1
Character: :, Code: 0111010, Frequency: 1
Character: U, Code: 1010101, Frequency: 1
Character: L, Code: 1001100, Frequency: 1
Character: E, Code: 1000101, Frequency: 1
Decompressed message: DR. RINCON SAYS: OS RULES

Option 1

Low Cost Option
Download this past answer in few clicks

22.99 USD

PURCHASE SOLUTION

Already member?


Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions