0% found this document useful (0 votes)
1 views

Your Id Soc2040 Sp Final Assignment Spring 2025

The document outlines the guidelines for the final assignment of SOC 2040 - Systems Programming for Spring Semester 2025, emphasizing that it is an individual assignment due by midnight on May 29, 2025. Students must upload a soft copy of their handwritten answers, which should include specific formatting and plagiarism checks, and any submission after the deadline will receive a grade of 0. Additionally, students are required to sign a pledge regarding academic integrity and follow strict instructions for submission to avoid penalties.

Uploaded by

maslo2005mem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Your Id Soc2040 Sp Final Assignment Spring 2025

The document outlines the guidelines for the final assignment of SOC 2040 - Systems Programming for Spring Semester 2025, emphasizing that it is an individual assignment due by midnight on May 29, 2025. Students must upload a soft copy of their handwritten answers, which should include specific formatting and plagiarism checks, and any submission after the deadline will receive a grade of 0. Additionally, students are required to sign a pledge regarding academic integrity and follow strict instructions for submission to avoid penalties.

Uploaded by

maslo2005mem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 142

DEPARTMENT OF CSE & ICE

SPRING SEMESTER 2025

SOC 2040 - SYSTEMS


PROGRAMMING

FINAL ASSIGNMENT
Submitted by
STUDENT NAME :
STUDENT ID :
SECTION NO :
SEMESTER YEAR : SPRING 2025
LEVEL : SOPHOMORE
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

FINAL ASSIGNMENT GUIDELINES


PLEASE NOTE THAT THIS IS AN INDIVIDUAL
ASSIGNMENT AND NOT A GROUP OR TEAM
ASSIGNMENT
DATE OF RELEASE :
Thursday, 22nd May 2025 at about 8pm at the
ASSIGNMENT SECTION AT THE ECLASS PORTAL
DATE OF UPLOAD :
Any day after 23rd May 2025 but till Thursday, 29th May
2025 well before 11.55 midnight at the ASSIGNMENT
SECTION AT THE ECLASS PORTAL
DEADLINE FOR UPLOADING OF FINAL ASSIGNMENT AT
THE ECLASS PORTAL IS THURSDAY, 29TH MAY 2025 BY
MIDNIGHT.
NO FINAL ASSIGNMENT WILL BE RECEIVED AFTER
MIDNIGHT ON THURSDAY, 29TH MAY 2025

2 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

NO SUBMISSION WILL LEAD TO A GRADE 0 FOR FINAL


ASSIGNMENT.
NO EMAILS WILL BE ENTERTAINED IN THIS REGARD AS
YOU ARE REQUIRED TO UPLOAD THE FINAL
ASSIGNMENT WELL BEFORE MIDNIGHT OF THURSDAY,
29TH MAY 2025.
PLEASE ADHERE TO THE SCHEDULE VERY STRICTLY.
FINAL ASSIGNMENT REPORT SHOULD BE
UPLOADED ONLY AT THE ECLASS PORTAL
NO HARDCOPY OF THE REPORT NEEDS TO BE
SUBMITTED
ONLY SOFT COPY OF THE REPORT UPLOADED
AT THE ECLASS IS ACCEPTED
THE NAME OF THE FINAL ASSIGNMENT REPORT MUST
BE CHANGED TO YOUR ID_SOC2040 SP FINAL
ASSIGNMENT SPRING 2025
FOR EXAMPLE, IF YOUR ID IS U231140 THEN YOUR
FINAL ASSIGNMENT REPORT MUST HAVE THE NAME :
U231140_SOC2040 SP FINAL ASSIGNMENT SPRING 2025

PLAGIARISM CHECK & CHEATING

3 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

ALL FINAL ASSIGNMENTS SUBMITTED WILL BE


THOROUGHLY CHECKED FOR PLAGIARISM USING A
VERY STANDARD PLAGIARISM SOFTWARE USED
ALL OVER THE WORLD.
COPYING ANSWERS FROM OTHER STUDENTS WILL
BE TAKEN AS A MALPRACTICE OR CHEATING CASE.
SUCH STUDENTS WILL GET GRADE 0 DIRECTLY.
PLEASE NOTE THAT FINAL ASSIGNMENT IS AN
INDIVIDUAL WORK AND NOT A GROUP
WORK.
EVERY STUDENT HAS TO SOLVE THE
QUESTIONS ON HIS/HER OWN WITHOUT
COPYING FROM OTHER STUDENTS.
FOR MOST OF THE QUESTIONS – ANSWERS
MUST BE HANDWRITTEN AND SCANNED AND
THEN COPIED TO THAT PART OF THE
QUESTIONS.
EVERY PAGE OF THE HANDWRITTEN ANSWER
SHEET MUST BEGIN WITH STUDENT NAME,
STUDENT ID, SECTION NO. AND STUDENT
SIGNATURE.
4 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

HAND WRITTEN ANSWERS SHEETS WITHOUT


THESE INFORMATION AND WITHOUT THE
SIGNATURE WILL GET A GRADE 0.
ON EVERY SHEET/PAGE AT THE TOP YOU MUST
WRITE YOUR NAME, ID AND SECTION NO.
IF A SHEET/PAGE DOES NOT CONTAIN THESE
INFORMATION, THEN THAT ANSWER
SHEET/PAGE WILL NOT BE GRADED
BEFORE UPLOADING YOUR FINAL ASSIGNMENT
REPORT AT THE ECLASS, PLEASE CHECK ALL THE
SHEETS FOR YOUR NAME, ID, SECTION NO. AND
SIGNATURE.
FOR ALL PROGRAMMING QUESTIONS, THE
PROGRAMS MUST BE EXECUTED ON LINUX IN
YOUR RESPECTIVE LAPTOPS AND SCREEN
SHOTS OF ALL THE PROGRAMS ENTERED,
COMMANDS TYPED, INPUTS GIVEN AND
OUTPUTS OBTAINED MUST BE INCLUDED IN
THE FINAL ASSIGNMENT REPORT AS PER THE
INSTRUCTIONS GIVEN IN EACH QUESTION.

5 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

ONLY FINAL ASSIGNMENT REPORT DOC FILE


( NO PDF VERSION) MUST BE UPLOADED
ALONG WITH ALL C PROGRAM FILES AND
ASSEMBLY LANGUAGE PROGRAM FILES (IN A
ZIPPED FOLDER).
NO PDF VERSION OF THE FINAL
ASSIGNMENT REPORT IS ACCEPTED, HENCE
NO PDF VERSION OF THE REPORT MUST BE
SUBMITTED – OTHERWISE GRADE 0 WILL
BE GIVEN.
ANSWERS FOR QUESTIONS PART A : [I],
[II], ]III], [IV], [V] & [IX]b) AND PART B : [III]a),
[IV]a) & [V]d) MUST BE HANDWRITTEN AND
SCANNED AND COPIED TO THE FINAL
ASSIGNMENT REPORT.
ANSWERS TYPED USING ANY EDITOR WILL
NOT BE GRADED, HENCE WILL GET A GRADE 0.
PLEASE NOTE THAT ONLY THOSE WHO HAVE UPLOADED
THE FINAL ASSIGNMENT BEFORE MIDNIGHT OF
THURSDAY, 29TH MAY 2025, THEY WILL BE ASKED TO
SUBMIT THE HANDWRITTEN ORIGINAL COPY OF THE
6 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

FINAL ASSIGNMENT FOR VERIFICATION AT A LATER


SPECIFIED DATE PERSONALLY.
THOSE WHO HAVE NOT UPLOADED THE FINAL
ASSIGNMENT WILL AUTOMATICALLY GET A GRADE 0
FOR FINAL ASSIGNMENT.
NO LAME EXCUSES WILL BE ENTERTAINED

IT IS MANDATORY FOR EVERY STUDENT TO SIGN THE


PLEDGE AND PROVIDE HIS/HER PHOTO BEFORE
WRITING THE ANSWERS FOR ALL THE QUESTIONS OF
FINAL ASSIGNMENT AND ALSO AFTER FINISHING
ANSWERING THE QUESTIONS, SIGN THE PLAGIARISM
STATEMENT GIVEN AT THE END OF THIS REPORT.
WITHOUT THESE, THIS FINAL ASSIGNMENT REPORT
WILL NOT BE GRADED.
YOU ARE HEREBY REQUIRED TO STRICTLY FOLLOW ALL
THE INSTRUCTIONS WITH MUCH MORE SERIOUSNESS.
Academic Dishonesty Policy
 In order for instructors to fairly assess the quality and quantity of a student's
learning (through course grades) as determined by work that students represent
as their own, a relationship of trust between instructor and student is essential.
 Because violations of academic integrity most often involve, but are not limited to,
efforts to deceive instructors, they represent a breach of the trust relationship between
instructor and student, and undermine the core values of the university.
For these reasons, the University and its instructors treat issues of academic
dishonesty as serious violations of academic trust, and conduct rigorous investigations of
students suspected of committing such acts.
ACTS OF ACADEMIC DISHONESTY INCLUDE, BUT ARE NOT LIMITED TO, THE FOLLOWING:
7 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

 the illegitimate use of materials in any form during a quiz or examination


 copying answers from the quiz or examination paper of another student
 plagiarizing (submitting as one's own ideas the work of another) or falsifying
materials or information used in the completion of any assignment which is graded or
evaluated as the student's individual effort
 submitting the same work for more than one course without the consent of the
instructors of each course in which the work is submitted
 copying material from a web page and submitting it as one's own work
 quoting extensively from a document without making proper references to the source
 If a student is found committing such acts in a quiz or home assignment or exam or
term paper or term project he/she will be given a grade F in that course

PLEDGE

INSERT YOUR
PHOTO HERE

I, ……………………………….….………..(write your name by hand)


bearing student ID …………………. belonging to section/group
number ……..………………, SOPHOMORE level fully understand
both the definition of plagiarism and the penalties for cheating (F
GRADE) and plagiarism. I pledge that I will not engage in any
activity that might be construed as plagiarism, a form of cheating. I
will not print, retype, or copy/paste material from the internet, books
or from my classmates (CSE/ICE SOPHOMORE CLASSES) or from

8 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

my seniors (CSE/ICE SOPHOMORE CLASSES) and submit it as my


work.

SIGNATURE DATE: 29-05-2025

(IT IS MANDATORY FOR EVERY STUDENT TO SIGN THIS PLEDGE AND


PROVIDE HIS/HER PHOTO. WITHOUT THESE THIS FINAL ASSIGNMENT
REPORT WILL NOT BE GRADED – TAKE PRINTOUT OF THIS PLEDGE PAGE,
AFFIX YOUR PHOTO, WRITE YOUR, NAME, ID & SECTION NO. BY HAND
AND PUT SIGNATURE, THEN SCAN THIS PAGE & PUT IT IN THIS DOC
REPORT)

PART – A
(TOTAL POINTS : 2400)
(QUESTIONS [I] TO [X] – TOTALLY 10 QUESTIONS ON TOPICS
TAUGHT BETWEEN WEEK1 TO WEEK 8)
[I]Convert each of the following binary numbers to 200 POINTS
(i) Unsigned form (B2U),
(ii) Signed Magnitude form (B2S),
(iii) One’s Complement form (B2O),
(iv) Two’s Complement form (B2T),
(v) Octal form, and
(vi) Hexadecimal form

a) 101101111011001111100111101101011010
b) 111010111001101101110011011001100111
ANSWER MUST BE HANDWRITTEN SHOWING ALL THE STEPS IN
ARRIVING AT THE SOLUTION. SCAN AND INSERT YOUR
HANDWRITTEN ANSWER HERE. ANSWER SHOULD BE WRITTEN
LEGIBLY AND BIG ENOUGH TO READ.

9 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

EVERY PAGE OF THE HANDWRITTEN ANSWER SHEET MUST BEGIN


WITH STUDENT NAME, STUDENT ID, SECTION NO. AND STUDENT
SIGNATURE.

10 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

11 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

12 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

13 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[II] Convert the following real numbers in decimal form to Binary form
(provide atleast 52 bits after the binary point in the result) 200
POINTS
a) N1= 98773896.87458365
b) N2= -653494985.94789357
c) N3= -80978462378.768997985
d) N4= 1234585789.984128765
ANSWER MUST BE HANDWRITTEN SHOWING ALL THE STEPS IN
ARRIVING AT THE SOLUTION. SCAN AND COPY YOUR
HANDWRITTEN ANSWER HERE. ANSWER SHOULD BE WRITTEN
LEGIBLY AND BIG ENOUGH TO READ.
EVERY PAGE OF THE HANDWRITTEN ANSWER SHEET MUST BEGIN
WITH STUDENT NAME, STUDENT ID, SECTION NO. AND STUDENT
SIGNATURE.

14 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

15 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

16 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[III] Convert the following decimal numbers into the IEEE 754 format for
SINGLE PRECISION floating point numbers and express each in packed
hex form : 200 POINTS
a) N1= 98773896.87458365
b) N2= -653494985.94789357
c) N3= -80978462378.768997985
d) N4= 1234585789.984128765

Perform the following operations and express the results in packed hex
form :
(i) N1 + N2 (ii) N1 - N3 (iii) N2 - N4 (iv) N3 +
N4

ANSWER MUST BE HANDWRITTEN SHOWING ALL THE STEPS IN


ARRIVING AT THE SOLUTION. SCAN AND COPY YOUR
HANDWRITTEN ANSWER HERE. ANSWER SHOULD BE WRITTEN
LEGIBLY AND BIG ENOUGH TO READ.
EVERY PAGE OF THE HANDWRITTEN ANSWER SHEET MUST BEGIN
WITH STUDENT NAME, STUDENT ID, SECTION NO. AND STUDENT
SIGNATURE.
17 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

18 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

19 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[IV] Given the following real numbers : 200 POINTS


N1= 98773896.87458365
N2= - 653494985.94789357
N3= - 80978462378.768997985
N4= 1234585789.984128765
Express them in IEEE 754 DOUBLE PRECISION floating point forms
and Perform the following operations and express the results in packed
hex form :
(ii) N1 - N2 (ii) N1 + N3 (iii) N2 + N4 (iv) N3 - N4

ANSWER MUST BE HANDWRITTEN SHOWING ALL THE STEPS IN


ARRIVING AT THE SOLUTION. SCAN AND COPY YOUR
HANDWRITTEN ANSWER HERE. ANSWER SHOULD BE WRITTEN
LEGIBLY AND BIG ENOUGH TO READ.
EVERY PAGE OF THE HANDWRITTEN ANSWER SHEET MUST BEGIN
WITH STUDENT NAME, STUDENT ID, SECTION NO. AND STUDENT
SIGNATURE.

20 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

21 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[V] Rewrite the following expressions involving x variable by replacing the


multiplication (*) and division (/) operations with the simple operations
left shift (<<) , right shift (>>), addition(+) and subtraction(-) operations :
a) x * 20000 100 POINTS
b) x * 30000
c) x * 40000
d) x * 50000
e) x * 60000
f) x * 70000
g) x * 80000
h) x * 90000
i) x * 100000
j) x / 2048
k) x / 65536

ANSWER MUST BE HANDWRITTEN SHOWING ALL THE STEPS IN


ARRIVING AT THE SOLUTION. SCAN AND INSERT YOUR
HANDWRITTEN ANSWER HERE. ANSWER SHOULD BE WRITTEN
LEGIBLY AND BIG ENOUGH TO READ.
22 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

EVERY PAGE OF THE HANDWRITTEN ANSWER SHEET MUST BEGIN


WITH STUDENT NAME, STUDENT ID, SECTION NO. AND STUDENT
SIGNATURE.

23 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[VI] Write a ‘C’ program to read a real number (both positive and negative)
in decimal form from the keyboard and convert this decimal number to
IEEE 754 DOUBLE PRECISION floating point number and display the
result in 64-bit BINARY and also packed HEX form. 300 POINTS
THE INTEGRAL PART OF THE INPUT DECIMAL REAL NUMBER
(i.e., before the decimal point) MUST CONTAIN ATLEAST EIGHT OR
MORE THAN EIGHT DECIMAL DIGITS AND THE FRACTIONAL
PART OF THE INPUT DECIMAL REAL NUMBER (i.e., after the
decimal point) MUST CONTAIN ATLEAST TWELVE OR MORE
THAN TWELVE DECIMAL DIGITS.
YOU NEED TO TRY OUT ATLEAST EIGHT DIFFERENT INPUT
COMBINATIONS OF REAL NUMBERS IN DECIMAL FORM AND
PROVIDE ALL THE SCREENSHOTS OF THE RESULTS
[INSERT HERE] SCREENSHOTS OF THE ENTIRE PROGRAM
ENTERED ON YOUR LAPTOP. SCREENSHOTS SHOULD BE
CLEAR, READABLE AND HAVING BIGGER FONTS
(REGULAR & READABLE FONTS FOR EVALUATION
OTHERWISE GRADE O WILL BE GIVEN):
24 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

25 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE COMMAND


ENTERED AND INPUTS GIVEN ON YOUR LAPTOP AND
SCREENSHOTS OF THE RESULTS OBTAINED ON YOUR
LAPTOP. SCREENSHOTS SHOULD BE CLEAR, READABLE
AND HAVING BIGGER FONTS (REGULAR & READABLE
FONTS FOR EVALUATION OTHERWISE GRADE O WILL BE
GIVEN)
YOU NEED TO TRY OUT ATLEAST EIGHT
DIFFERENT INPUT COMBINATIONS OF REAL
NUMBERS IN DECIMAL FORM AND PROVIDE ALL
THE SCREENSHOTS OF THE RESULTS

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.

26 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

ALL COMMANDS ENTERED MUST HAVE THIS PROMPT


WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

27 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[VII] Write a ‘C’ program to read an IEEE 754 DOUBLE PRECISION


floating point number in hex form(64 BITS - 16 HEX DIGITS) from
the keyboard and convert it to THE CORRESPONDING REAL
NUMBER IN DECIMAL FORM and ALSO CONVERT THIS REAL
NUMBER IN DECIMAL FORM TO BINARY FORM and display the
results.
YOU NEED TO TRY OUT ATLEAST EIGHT DIFFERENT INPUT
COMBINATIONS OF IEEE 754 DOUBLE PRECISION FLOATING
POINT NUMBERs IN HEX FORM AND PROVIDE ALL THE
SCREENSHOTS OF THE RESULTS 300 POINTS
[INSERT HERE] SCREENSHOTS OF THE ENTIRE PROGRAM
ENTERED ON YOUR LAPTOP. SCREENSHOTS SHOULD BE
CLEAR, READABLE AND HAVING BIGGER FONTS
(REGULAR & READABLE FONTS FOR EVALUATION
OTHERWISE GRADE O WILL BE GIVEN):

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :

28 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

$PS1=”\d \t \u@\h \#\$”


TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

[INSERT HERE] SCREENSHOTS OF THE COMMAND


ENTERED AND INPUTS GIVEN ON YOUR LAPTOP AND
SCREENSHOTS OF THE RESULTS OBTAINED ON YOUR
LAPTOP. SCREENSHOTS SHOULD BE CLEAR, READABLE
AND HAVING BIGGER FONTS (REGULAR & READABLE
FONTS FOR EVALUATION OTHERWISE GRADE O WILL BE
GIVEN)
YOU NEED TO TRY OUT ATLEAST EIGHT
DIFFERENT INPUT COMBINATIONS OF REAL
NUMBERS IN DECIMAL FORM AND PROVIDE ALL
THE SCREENSHOTS OF THE RESULTS

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
29 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

ALL COMMANDS ENTERED MUST HAVE THIS PROMPT


WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

30 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[VIII] Write an X86-64 ASSEMBLY LANGUAGE PROGRAM to read a


LIST or ARRAY OF ‘n’ names or strings of characters of any length
(from minimum 15 characters to maximum 1024 characters) from the
keyboard and print the list of names entered. 300
POINTS
The value of ‘n’ (number of names) must be read from the keyboard
by giving a prompt message to the user “ENTER VALE OF n :”
After reading the value of ‘n’ from the keyboard, then read the list of n
(for example n=20) names from the keyboard by giving a prompt
message to the user “NOW ENTER LIST of n=20 NAMES\n:”, for
example.

Then perform the following operations on the list of names :


a) SORT or rearrange the names in the list in Alphabetical order and
print the sorted list with a message first “LIST OF NAMES IN
ALPHABETICAL ORDER:\n” and then print the names in
alphabetical order one after another

31 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

b) REVERSE SORT or rearrange the names in the list in reverse


Alphabetical order and print the sorted list with a message first “LIST
OF NAMES IN REVERSE ALPHABETICAL ORDER: \n” and
then print the names in reverse alphabetical order one after another
c) SEARCH FOR A NAME – Search for a given name in the list either
specifying first name or family name. If a name is found then print
“NAME FOUND” and also print the position of the name in the list
(i. e., for example- if name entered matches with 15 th name in the list
then print “NAME OCCURS AT POSITION : 15 “)
If there are multiple matches, then you should print all these names and
their positions in the list.
If search is unsuccessful then print “NAME NOT FOUND”
d) CONVERT UPPERCASE TO LOWERCASE – Convert all the
uppercase alphabets in each name to lowercase and print the output on
the screen
e) CONVERT LOWERCASE TO UPPERCASE – Convert all the
lowercase alphabets in each name to uppercase and print the output on
the screen
f) WORD & CHARACTER COUNT – Count the number of words and
number of characters in all the names in the list and print the output on
the screen.

YOU NEED TO TRY OUT ATLEAST EIGHT DIFFERENT LIST OF 10 TO


30 NAMES AND PROVIDE ALL THE SCREENSHOTS OF THE
RESULTS
[INSERT HERE] SCREENSHOTS OF THE ENTIRE PROGRAM
ENTERED ON YOUR LAPTOP. SCREENSHOTS SHOULD BE
CLEAR, READABLE AND HAVING BIGGER FONTS
(REGULAR & READABLE FONTS FOR EVALUATION
OTHERWISE GRADE O WILL BE GIVEN):

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
32 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

ALL COMMANDS ENTERED MUST HAVE THIS PROMPT


WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

33 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE COMMAND


ENTERED AND INPUTS GIVEN ON YOUR LAPTOP AND
SCREENSHOTS OF THE RESULTS OBTAINED ON YOUR
LAPTOP. SCREENSHOTS SHOULD BE CLEAR, READABLE
AND HAVING BIGGER FONTS (REGULAR & READABLE
FONTS FOR EVALUATION OTHERWISE GRADE O WILL BE
GIVEN):
YOU NEED TO TRY OUT ATLEAST EIGHT DIFFERENT LIST
OF 10 TO 30 NAMES AND PROVIDE ALL THE
SCREENSHOTS OF THE RESULTS

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
34 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR


EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

35 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[IX] a) You are given the following ‘C’ program containing recursive
function to count the number of 1’s in a given number x(long int –
64bits). Write the equivalent recursive function in x86-64
assembly language and Run the program for different values of
x(64 bits) and display the result on the screen.
150 POINTS

int main()
{
long int x, num1s;
scanf(“%ld”, &x);
num1s= onescnt(x);
printf(“Number of 1s in the given number %ld = %ld\n”, x,
num1s);
}

36 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

long onescnt(long n)
{
If (n == 0)
return 0;
else
return ( n & 0x1) + onescnt(n >>= 1);
}
YOU NEED TO TRY OUT ATLEAST EIGHT DIFFERENT VALUES FOR
INPUT x WHERE x IS 64 BITS AND PROVIDE ALL THE
SCREENSHOTS OF THE RESULTS
[INSERT HERE] SCREENSHOTS OF THE ENTIRE X86-64
ASSEMBLY LANGUAGE PROGRAM ENTERED ON YOUR
LAPTOP. SCREENSHOTS SHOULD BE CLEAR, READABLE
AND HAVING BIGGER FONTS (REGULAR & READABLE
FONTS FOR EVALUATION OTHERWISE GRADE 0 WILL BE
GIVEN):
BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST
ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

37 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE COMMAND


ENTERED AND INPUTS GIVEN ON YOUR LAPTOP AND
SCREENSHOTS OF THE RESULTS OBTAINED ON YOUR
LAPTOP. SCREENSHOTS SHOULD BE CLEAR, READABLE
AND HAVING BIGGER FONTS (REGULAR & READABLE
FONTS FOR EVALUATION OTHERWISE GRADE 0 WILL BE
GIVEN):
YOU NEED TO TRY OUT ATLEAST EIGHT DIFFERENT
VALUES FOR INPUT x WHERE x IS 64 BITS AND PROVIDE
ALL THE SCREENSHOTS OF THE RESULTS

38 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

39 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[IX] b) Draw the stack structure showing the stack contents when the assembly
language recursive function onescnt is invoked with the value for
x=11011011. You are required to show clearly the stack frame contents
for all Recursive calls and Recursive returns of the function onescnt
for x=11011011. Show also the x86-64 processors register contents
during every recursive call and every recursive return. 150
POINTS
YOU MUST DRAW ALL THE STACK STRUCTURE FIGURES BY
HAND ON SEPARATE SHEETS AND THEN SCAN AND INSERT
HERE. IN ORDER TO GET POINTS – ALL DRAWN FIGURES
MUST BE CLEAR , QUITE READABLE AND BIG & BOLD
ENOUGH.
40 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

CUT & PASTE OF THE FIGURES FROM THE TEXT BOOKS,


LECTURE SLIDES AND OTHER AVAILABLE MATERIALS ON
THE INTERNET IS TOTALLY PROHIBITED. IF FOUND – WILL
BE GIVEN GRADE 0 WITHOUT GOING THROUGH ANY PART
OF THIS QUESTION. ONLY HANDWRITTEN
SOLUTION/FIGURE IS ACCEPTED.
EVERY PAGE OF THE HANDWRITTEN ANSWER SHEET
MUST BEGIN WITH STUDENT NAME, STUDENT ID, SECTION NO.
AND STUDENT SIGNATURE.

41 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[X] WRITE THE ANSWER IN THE BOX PROVIDED AGAINST EACH OF


THE MULTIPLE CHOICE QUESTIONS 300 POINTS
READ THE QUESTIONS CAREFULLY AND CORRECTLY.
FOR THIS QUESTION, ANSWER MUST BE WRITTEN, THAT IS,
TYPED IN THE BOX PROVIDED AGAINST EACH QUESTION IN
THIS PART ONLY
1) Datapath components of a processor are …………………………….
a) Instruction and Data Caches
b) Program Counter & Register File
c) Arithmetic and Logic Unit

42 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

d) All of the above

2) ………..…. is used to translate a program written in assembly language instructions to


machine language instructions or object code
a) Compiler b) Preprocessor c) Assembler d) Linker

3) ………..…. is used to translate a program written in high-level language to assembly


language/ machine language instructions or object code
a) Compiler b) Preprocessor c) Assembler d) Linker

4) In order to convert uppercase alphabet letter to lowercase alphabet letter, …….. is to


be added to its equivalent ASCII code
a) 8 b) 16 c) 32 d) 64

5) Choose the correct order of the following steps in the compilation system
a) Compiler, Pre-processor, Assembler, Linker
b) Pre-processor, Assembler, Compiler, Linker
c) Pre-processor, Compiler, Assembler, Linker
d) Assembler, Preprocessor, Compiler, Linker

6) ………………. is an interface between a computer user and computer


hardware.
a) shell b) kernel c) compiler d) linker

7) ………………. is an interface between a computer user and operating system.


a) shell b) kernel c) compiler d) linker

8) The default shell on most linux distributions is …………………..


a) sh b) ksh c) csh d) bash

9) ………..…. combines object files created by the assembler and library routines to
produce a single executable object code
a) Compiler b) Preprocessor c) Assembler d) Linker

10) A Static RAM(SRAM) 1-bit storage cell uses …………….. Transistors(s) & …………..
capacitor
a) 4 & 0 b) 1 & 1 c) 6 & 1 d) 6 & 0

11) A Dynamic RAM (DRAM 1-bit storage cell uses …………….. Transistors(s) &
………….. capacitor
a) 4 & 0 b) 1 & 1 c) 6 & 1 d) 6 & 0

43 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

12) State one similarity between SRAM & DRAM semiconductor devices.
……………………
a) Both are Electrically Erasable Programmable Read Only Memory devices
b) Both use capacitors to store the data
c) Both are Non-volatile devices
d) Both are Volatile devices

13) Flash memory is a kind of ……………………………………………………


a) EEPROM with byte-erasure capability
b) EEPROM with block-erasure capability
c) EPROM with read-write capability
d) Volatile device with read-write capability

14) .............. is used to construct Main memory


a)EPROM b)EEPROM c)SRAM d)DRAM

15) .............. is used to construct Cache memory


a)EPROM b)EEPROM c)SRAM d)DRAM

16) Provide the parameter(s) required to access a file on the hard disk.............
a)Surface number b)Track number c)Sector Number
d)All of the above

17) If the processor has a 36-bit address bus, then the addressing capability is ...........
memory locations
a)64 Giga b)64 Mega c)64 Tera d)64 Peta

18) .............. contains the address of the next instruction to be fetched and executed
a) Program Counter b)Instruction Register c)Instruction Cache d)Status Register

19) ASCII code for character 'c' is ...


a)65 b)97 c)67 d)99

20) Arrange the following in the order in which they appear in the Memory Hierarchy
Pyramid from top to the bottom of the pyramid
1. Primary Memory (Main Memory) devices
2. L3 Cache Memory
3. Secondary Memory devices
4. L1 Cache Memory
5. Registers
6. L2 Cache Memory
a)1,3,5,6,2,4 b)5,4,6,2,1,3 c)3,1,2,6,4,5 d)5,2,6,4,1,3

21) Write the following operations in the correct order in which they are performed in the
Fetch-Execute Cycle by the processor
1. Read Operands
44 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

2. Instruction Execute
3. Instruction Decode
4. Writeback Result
5. Instruction Fetch
a)5,1,2,3,4 b)5,3,1,2,4 c)3,5,1,2,4 d)5,3,2,1,4

22) Provide the correct order of the levels in the Programmer's view of a Computer
System
1. Microarchitecture
2. Operating System
3. Physical Design
4. Application Program (High level Language)
5. Instruction set Architecture
6. Assembly language
a)6,4,5,2,3,1 b)4,6,2,5,1,3 c)4,6,2,5,3,1 d)6,4,5,2,1,3

23) What are the advantages of High level languages?


a) Faster Program Development
b) Easier Program Maintenance
c) Smoother Program Portability
d) All of the Above

24) What are the reasons for learning Assembly Language?


a) Accessibility to System Hardware
b) Achieving Space and Time Efficiency
c) Writing a compiler for a high-level language
d) All of the above

25) ASCII code for numeral 2 is ...


a)67 b)48 c)97 d)50

26) Linux command to login to a remote machine is ..............


a)ftp b)telnet c)ping d)ifconfig
27) Write the following regions of the virtual address space in the correct order in which
they appear in a Process Virtual Address Space from bottom to top.
1. Run-time Heap
2. Read-only Code and Data
3. User Stack
4. Read/Write data
5. Kernel Virtual Memory
6. Memory Mapped region for Shared Libraries
a)5,3,6,1,4,2 b)2,4,1,6,3,5 c)2,1,4,3,6,5 d)5,3,1,6,4,2

28) The Intel Core i7 processor can have each core executing ....... threads
a)1 b)2 c)4 d)8

45 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

29) The ........... modifies the original C program according to directives that begin with the
# character.
a)preprocessor(cpp) b)compiler(cc1) c)assembler(as) d)linker(ld)

30) The............. translates the text file C program into the text file which contains an
assembly-language program.
a)preprocessor(cpp) b)compiler(cc1) c)assembler(as) d)linker(ld)

31) B2U(110011001100) =
a) 1228 b) -819 c) 3276 d) -820

32) B2S(1101101111011011)
a) 56283 b) -9252 c) -9253 d) -23515

33) B2O(10111001) =
a) -70 b) -71 c) -57 d) 185

34) B2T(110011001100) =
a) 3276 b) 1228 c) -819 d) -820

35) Convert decimal 478 to binary =


a) 011110111 b) 111011110 c) 011101111 d) 111101110

36) Convert octal 367 to decimal =


a) 347 b) 247 c) 346 d) 246

37) Convert hexadecimal 0xFEBD to decimal =


a) 65536 b) 64213 c) 65213 d) 64536

38) Convert decimal 5267 to hexadecimal =


a) 0x1594 b) 0x1934 c) 0x1493 d) 0x1473

39) Convert the following binary number 10010111 in Signed-Magnitude form to


equivalent decimal value.......
a)151 b) -23 c)-105 d)128

40) Convert the following binary number 11011101 in Two’s Complement form to
equivalent decimal value ...........
a) 221 b)93 c) -35 d)-221

41) Convert the following real number in binary form 11011010.10101011 to Decimal
form.......
a) 219.66796875 b)218.69856763 c) 218.66796875 d)220.66796875

42) Convert the following real number in binary form 1101010101001011.01011011 to


Decimal form .......

46 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

a) 54604.55346875 b)54603.55346875 c)54604.35546875 d) 54603.35546875

43) Convert the following real number in decimal form 736.8365 to binary form ............
a)1011100000.0110101100010010 b) 1011100000.1101011000100100
c)1011010010.1101011000100100 d)1011010010.0110101100010010

44) Convert the following real number in decimal form 4678.768 to binary form ............
a)1001001000110.1100010010011011 b)1001001000110.1110010010110110
c)1000101010010.1100010010011011 d)1000101010010.1110010010110110

45) Given x = 0x45 and y = 0xBA compute x & y


a) 0x4A b) 0 c)0xB5 d)1
46) Number of bytes required to store integer of type long int in memory is ..........
a) 16 b)4 c)8 d) 2

47) The maximum unsigned integer that can be stored in an 8-bit register is ...........
a)256 b)128 c)127 d)255

48) The maximum unsigned integer that can be stored in an 16-bit register is ...........
a) 32768 b)32767 c) 65535 d)65536

49) The maximum positive integer that can be stored in an 8-bit register in Two's
complement form is ...........
a) 256 b)128 c)255 d) 127

50) The maximum positive integer that can be stored in an 16-bit register in Two's
complement form is ...........
a) 65535 b)32768 c) 32767 d)65536

51) The minimum negative integer that can be stored in an 8-bit register in Two's
complement form is ...........
a)-127 b)-128 c)-255 d)-256
52) The minimum negative integer that can be stored in an 16-bit register in Two's
complement form is ...........
a)-327677 b)-32768 c)-65535 d)-65536

53) Given a binary number 00010000, Shif the bits in this number left logically by two
bits and then write the equivalent decimal number ...........
a)128 b)32 c)16 d)64

54) Given a binary number 11110000, shift the bits in this number right logically by two
bits and then write the equivalent decimal number............
a)90 b)-4 c)-8 d)60

47 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

55) Given a binary number 11110000, shift the bits in this number right arithmetically by
two bits and then write the equivalent decimal number............
a)-8 b)-16 c)-4 d)60

56) Given a hexadecimal 0xC493, Sign-extend it to 32-bit ...............


a) 0x0000C493 b) 0xFFFFC493 c)0x00FFC493 d)0xFF00C493

57) Given a hexadecimal 0x3B6D, Sign-extend it to 32-bit .................


a) 0x00FF3B6D b)0xFFFF3B6D c) 0x00003B6D d)0xFF003B6D

58) Given a 4-bit negative integer in Two's complement form, what value is to be added to
convert it to an equivalent unsigned integer............
a) -8 b)-16 c) +16 d)+8

59) Given x = 0x3C and y = 0xC3 compute x & y


a) 0x33 b) 0xCC c) 0 d) 1

60) Given x = 0x3C and y = 0xC3 compute x && y


a) 0x33 b) 0xCC c) 0 d) 1

61) Convert the following decimal number -121.6875 into the IEEE 754 format for
single precision floating point number and express in packed hex form :
a) 0x42F36000 b) 0xC2F36000 c) 0xD2F63000 d) 0x42F63000

62) The number of bytes required to store single precision and double precision
floating point numbers using IEEE 754 format in computer memory respectively are
……..
a) 32, 64 b) 8, 16 c) 16, 32 d) 4, 8

63) The Bias used in single precision and double precision floating point numbers
using IEEE 754 format respectively are ………………
a) 128, 1024 b) 127, 2047 c) 127, 1023 d) 255, 1023

64) Rewrite the expression x / 512 by replacing division with right shift operation.
a) x >> 7 b) x >> 8 c) x >> 9 d) x >> 10
65) Rewrite the expression x * 200 by replacing multiplication with left shift, addition
and/or subtraction operations
a) x<<8 - x<<5 - x<<4- x<<3 b) x << 8 - x << 3 - x << 1
c) x << 9 - x << 5 - x << 1 d) x << 7 + x << 6 + x<< 1 + x

66) Rewrite the expression x << 10 - x << 4 - x << 3 using only multiplication
operation
a) x * 500 b) x * 2000 c) x * 1000 d) x * 4000

48 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

67) The addition of two w-bit signed integers will generate a maximum of ...... bits in the
sum result.
a) w^2 b)w c)2*w d) w+1

68) The multiplication of two w-bit signed integers will generate a maximum of ........ bits
in the product result.
a) 2w+1 b)w+1 c) 2*w d)w*w

69) The following Two's complement 8-bit addition 01111111 + 01111111 generates the
result ............ with ...........
a)11111110, overflow b)11111110, no overflow
c)011111110, overflow d)011111110, no overflow

70) The following Two's complement 8-bit addition 10000000 + 10000001 generates the
result ............ with ...........
a) 00000001, no overflow b) 00000001, overflow
c)100000001, overflow d)100000001, no overflow

71) The following Two's complement 8-bit subtraction 01111111 - 10000001 generates the
result ............ with ...........
a) 011111110, overflow b)11111110, no overflow
c) 11111110, overflow d)011111110, no overflow

72) The following Two's complement 8-bit subtraction 10000000 - 01111111 generates the
result ............ with ...........
a) 100000001, no overflow b)00000001, no overflow
c)100000001, overflow d) 00000001, overflow

73) Negation(x) = ..........


a) always 0 b)One's Complement(x)
c) Two's Complement(x) d)always 1

74) Given an 8-bit Two's complement number x =10000000, Compute Negation of x ...
a)128 b)-128 c)127 d)-127

75) Given an 8-bit Two's complement number x =00000000, Compute Negation of x ...
a)-1 b)0 c)-128 d)127
76) Convert the following decimal number -127.75 into the IEEE 754 format for single
precision floating point number and express in packed hex form :
a) 0xC2F36000 b)0x42FF8000 c) 0xC2FF8000 d)0x42F36000

77) Convert the following decimal number -121.6875 into the IEEE 754 format for single
precision floating point number and express in packed hex form :
a) 0x42F36000 b) 0xC2F36000 c)0xD2F63000 d)0x42F63000

49 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

78) The number of bits required to store single precision floating point numbers using
IEEE 754 format in computer memory is……..
a)16 b)32 c)64 d)80

79) The number of bits required to store double precision floating point numbers using
IEEE 754 format in computer memory is .....
a)16 b)32 c)64 d)80

80) The number of bits required to store long double precision floating point numbers
using IEEE 754 Extended format (Intel) in computer memory is .....
a)16 b)32 c)64 d)80

81) The Bias used in single precision floating point numbers using IEEE 754 format is
……
a)1023 b)127 c)128 d)2047

82) The Bias used in double precision floating point numbers using IEEE 754 format is….
a)127 b)128 c)2047 d)1023

83) Rewrite the expression x * 65555 by replacing multiplication with left shift, addition
and/or subtraction operations
a)x<<16 + x<<4 + x<<2 + x b)x<<16 + x<<5 - x<<4
c)x<<16 + x<<4 + x<<3 d)x<<17 - x<<16 - x<<4

84) Rewrite the expression x << 13 - x << 7 - x << 6 using only multiplication
operation
a)x*8500 b)x*8000 c)x*9000 d)x*9500

85) Rewrite the expression x<<15 + x<<12 + x<<11 + x<<10 + x<<6 -x using only
multiplication operation.
a)x*40000 b)x*49999 c)x*39999 d)x*59999

86) The width of the Biased Exponent field E in IEEE single precision floating point
format is ..
a)15 bits b)23 bits c)11 bits d)8 bits

87) The width of the Biased Exponent field E in IEEE Double precision floating point
format is .......
a)15 bits b)23 bits c)11 bits d)8 bits

88) The width of the Biased Exponent field E in IEEE Extended precision(Intel) floating
point format is ............
a)23 bits b)8 bits c)11 bits d)15 bits

89) The width of the Fractional Mantissa field F in IEEE single precision floating point
format is ...............

50 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

a)52 bits b)15 bits c)23 bits d)64 bits

90) The width of the Fractional Mantissa field F in IEEE Double precision floating point
format is ..............
a)23 bits b)64 bits c)15 bits d)52 bits

91) The width of the Fractional Mantissa field F in IEEE Extended precision(Intel)
floating point format is ..........
a)15 bits b)64 bits c)11 bits d)23 bits

92) In single precision floating point format, Two combinations in the true exponent range
reserved for representing special cases are .............
a)0, 255 b)127, 128 c)-1023, -1024 d)-127, -128

93) In Double precision floating point format, Two combinations in the true exponent
range reserved for representing special cases are .............
a)-127, -128 b)-1023, -1024 c)0, 255 d)127, 128

94) The range of floating point numbers that can be stored in a single precision floating
point format is ...
a)10^-64 to 10^+64 b)10^-32 to 10^+32 c)10^-38 to 10^+38 d)10^-308 to 10^+308

95) The range of floating point numbers that can be stored in a double precision floating
point format is .....
a)10^-64 to 10^+64 b)10^-32 to 10^+32 c)10^-38 to 10^+38 d)10^-308 to 10^+308

96) The IEEE standard single precision floating point representation in hex for +0 is ........
a)0xFFC00000 b)0x00000000 c)0xFF800000 d)0x80400000

97) The IEEE standard single precision floating point representation in hex for -
INFINITY is ............
a)0x00000000 b)0x80400000 c)0xFF800000 d)0xFFC00000

98) The IEEE standard single precision floating point representation in hex for
Denormalized Number -0.1 x 2^-126 is ............
a)0xFFC00000 b)0x80400000 c)0xFF800000 d)0x00000000

99) The IEEE standard single precision floating point representation in hex for Not A
Number (NaN) is ............
a)0xFFC00000 b)0x80400000 c)0xFF800000 d)0x00000000
100) Convert the following decimal number 121.6875 into the IEEE 754 format for single
precision floating point number and express in packed hex form :
a)0xC2FF8000 b)0x42F36000 c)0x42FF8000 d)0xC2F36000

101) Convert the following decimal number - 39.525 into the IEEE 754 format for single
precision floating point number and express in packed hex form :

51 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

a)0xC2F36000 b)0x42F36000 c)0xC21E1999 d)0xC2FF8000

102) Given N1 = 736.8365 & N2 = -985.78357 and Perform the operation N1 + N2 and
express the result in packed hex form :
a)0xC2FF8000 b)0x42FF8000 c)0xC2F36000 d)0xC378F274

103) Given N1 = 736.8365 & N3 = 4678.768 and Perform the operation N1 + N3 and
express the result in packed hex form :
a)0xC2FF8000 b)0x42FF8000 c)0x45A93CD6 d)0xC2F36000

104) Given N2 = -985.78357 & N3 = 4678.768 and Perform the operation N2 - N3 and
express the result in packed hex form after rounding off the mantissa :
a)0xC2FF8000 b)0xC5B1046A c)0x42FF8000 d)0xC2F36000

105) Given N2 = -985.78357 & N4= -85789.9841875 and Perform the operation N2 + N4
and express the result in packed hex form after rounding off the mantissa :
a)0xC7A97BE2 b)0xC2FF8000 c)0x42FF8000 d)0xC2F36000

106) Linux Command to convert C language program to corresponding assembly


language program
a)gcc -Og -c mstore.c b)gcc mstore.c -o mstore
c)gcc -Og -S mstore.c d)objdump -d mstore

107) What is the data stored in %rbx register after the execution of following
instruction: movq $0x8bcdef8960, %rbx
a)0x8888888bcdef8960 b)0x1111118bcdef8960
c)0xffffff8bcdef8960 d)0x0000008bcdef8960

108) If %rbx = 9000 and %rsi =50 then determine the Effective Address computed in the
following instructions:
movq -98(%rbx, %rsi, 4), %rax
a)9298 b)9298 c)9112 d)0x9112

109) Given two signed numbers a and b, one of the following conditions detect overflow
after signed addition (t= a + b )
a) If a > 0 , b < 0 and t < 0
b) If a < 0, b < 0 and t < 0
c) If a > 0, b > 0 and t < 0
d) If a < 0, b > 0 and t > 0

110) Given %rsi= 2000 which is the starting address of the memory area, Then
determine how data is stored in the memory after the execution of the following
instructions:
movq $0xcabdadfeed123456, %rax
movq %rax, (%rsi)
a)2000:ac, 2001:db, 2002:da, 2003:ef, 2004:de, 2005:21, 2006:43, 2007:65

52 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

b)2000:ac, 2001:db, 2002:da, 2003:ef, 2004:de, 2005:21, 2006:43, 2007:65


c)2000:ca, 2001:bd, 2002:ad, 2003:fe, 2004:ed, 2005:12, 2006:34, 2007:56
d)2000:56, 2001:34, 2002:12, 2003:ed, 2004:fe, 2005:ad, 2006:bd, 2007:ca

111) Indicate the function performed by the following x86-64 assembly language
program segment.
movq (%rdi), %rax
movq (%rsi), %rdx
movq %rdx, (%rdi)
movq %rax, (%rsi)
a)Copying the contents of the register %rdx to %rax
b)Copying the contents of the register %rax to %rdx
c)Exchange of the contents of registers %rax and %rdx using memory locations
d)Exchange of the contents of memory locations pointed to by registers %rdi and %rsi
using temporary registers

112) Choose the correct program segment containing x86-64 assembly language
instructions to multiply x in rax register by 144 using only leaq and shlq (shift left
instruction)
a) leaq (%rax, %rax, 1), %rax b) leaq (%rax, %rax, 2), %rax
shlq $32, %rax shlq $16, %rax

c) leaq (%rax, %rax, 4), %rax d) leaq (%rax, %rax, 8), %rax
shlq $8, %rax shlq $4, %rax

113) Indicate the function performed by the following x86-64 assembly language
program segment
xorq %rbx, %rax
xorq %rax, %rbx
xorq %rbx, %rax
a) Exclusive or of the numbers in registers %rax and %rbx
b) Addition of two numbers in registers %rax and %rbx
c) Copying the contents of the register %rax to %rbx
d) Exchange of the contents of registers %rax with %rbx without using any temporary
register or memory location

114) Given two signed numbers a and b, one of the following conditions detect overflow
after signed subtraction (t= a - b )
a) If a > 0 , b < 0 and t > 0 b) If a < 0, b < 0 and t < 0
c) If a > 0, b > 0 and t > 0 d) If a < 0, b > 0 and t > 0
115) Indicate the function performed by the following x86-64 assembly language
program segment
addq %rbx, %rax
subq %rax, %rbx
negq %rbx
subqq %rbx, %rax

53 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

a) Subtraction of two numbers in registers %rax and %rbx


b) Addition of two numbers in registers %rax and %rbx
c) Exclusive or of the contents of the register %rax to %rbx
d) Exchange of the contents of registers %rax with %rbx without using any temporary
register or memory location

116) Indicate the value computed in register %rax by the following x86-64 assembly
language recursive function if the register %rdi contains 0xFEEDBAC5 initially.

rec_fun:
movq $0, %rax
testq %rdi, %rdi
je DOWN
pushq %rbx
movq %rdi, %rbx
andq $1, %rbx
shrq %rdi
call rec_fun
addq %rbx, %rax
popq %rbx
DOWN: ret
a) 42 b) 22 c) 32 d) 12

117) Write x86-64 assembly language instructions to multiply x in %rax register by 1280
using only leaq and shlq (shift left instructions)

a)leaq(%rax, %rax, 8), %rax b)leaq(%rax, %rax, 4), %rax


salq $6, %rax salq $8, %rax

c)leaq(%rax, %rax, 1), %rax d)leaq(%rax, %rax, 2), %rax


salq $9, %rax salq $7, %rax

118) Write x86-64 assembly language instructions to multiply x in %rax register by 3072
using only leaq and shlq (shift left instructions)
a)leaq(%rax, %rax, 4), %rax b)leaq(%rax, %rax, 2), %rax
salq $9, %rax salq $10, %rax

c)leaq(%rax, %rax, 1), %rax d)leaq(%rax, %rax, 8), %rax


salq $12, %rax salq $7, %rax
119) Consider the following memory area containing data and intel x86-64 assembly
program segment given below:
Address Data Address data
------- ----- ------- -----
list: 2000 c9 2009 12
2001 73 2010 9b
2002 49 2011 ` df

54 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

2003 ab 2012 5e
2004 ad 2013 47
2005 fe 2014 83
2006 ed 2015 c8
2007 ca 2016 7e
2008 de 2017 5f

movq $list, %rbx


movq $2, %rsi
leaq (%rbx, %rsi, 4), %rax
movq (%rbx, %rsi, 4), %rcx

Determine the contents of the registers %rax and %rcx after executing the above
assembly program segment.
a)%rax=2008, %rcx= 0xde129bdf5e4783c8 b)%rax=0xde129bdf5e4783c8, %rcx=2008
c)%rax=2006, %rcx= 0xc883475edf9b12de d)%rax=2008, %rcx= 0xc883475edf9b12de

120) Write x86-64 assembly language instructions to multiply x in %rax register by 1024
using only leaq and shlq (shift left instructions)
a)leaq(%rax, %rax, 4), %rax b)leaq(%rax, %rax,1), %rax
salq $6, %rax salq $9, %rax

c)leaq(%rax, %rax, 2), %rax d)leaq(%rax, %rax, 8), %rax


salq $8, %rax salq $5, %rax

121) Given initially %rax=100 & %rbx=200, write the values in the registers %rax &
%rbx after the execution of the following x86-64 assembly language program segment
addq %rbx, %rax
subq %rax, %rbx
negq %rbx
subqq %rbx, %rax

a) %rax= 200, %rbx = 100 b) %rax= 100, %rbx = 100


c) %rax= 300, %rbx = 200 d) %rax= 200, %rbx = 300

122) The syscall invokes the ......... interrupt instruction.


a)int 0x128 b)int 80 c)int 0x80 d)int 32

123) Write a single assembly language instruction which performs the same operation as
performed by the following program segment :
movq %rax, %rcx
movq %rbx, %rdx
notq %rcx
notq %rdx
andq %rdx, %rax
andq %rcx, %rbx

55 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

orq %rbx, %rax


a)xorq %rbx, %rax b)xorq %rcx, %rdx c)subq %rbx, %rax d)addq %rbx, %rax

124) The arguments to be passed to the C library printf(format, arg) function before
calling the printf function in assembly language program to display an arg integer
value.
a)%rsi = $format, %rdi= arg, %rax=0 b)%rdi = $format, %rsi= arg, %rax=0
c)%rdi = $format, %rdx= arg, %rbx=0 d)%rdi = $format, %rsi= arg, %rbx=0

125) The arguments to be passed to the C library scanf(format, &arg) function before
calling the printf function in assembly language program to display an arg integer
value.
a)%rdi = $format, %rsi= arg, %rax=0 b)%rsi = $format, %rdi= &arg, %rax=0
c)%rdi = $format, %rsi= &arg, %rbx=0 d)%rdi = $format, %rsi= &arg, %rax=0

126) The arguments to be passed to the syscall keyboard sys_read function are .........
a)%rax=0, %rdi=1, %rdx = Buffer starting address, %rsi=Buffer size
b)%rax=0, %rdi=0, %rdx = Buffer starting address, %rsi=Buffer size
c)%rax=0, %rdi=0, %rsi = Buffer starting address, %rdx=Buffer size
d)%rax=1, %rdi=0, %rsi = Buffer starting address, %rdx=Buffer size

127) The arguments to be passed to the syscall display unit sys_write function are .........
a)%rax=0, %rdi=1, %rdx = Buffer starting address, %rsi=Buffer size
b)%rax=1, %rdi=1, %rsi = Buffer starting address, %rdx=Buffer size
c)%rax=0, %rdi=0, %rdx = Buffer starting address, %rsi=Buffer size
d)%rax=1, %rdi=1, %rdx = Buffer starting address, %rsi=Buffer size

128) The arguments to be passed to the syscall sys_exit function are .........
a)%rax=60, %rdi=0, %rdx = Buffer starting address, %rsi=Buffer size
b) %rax=0, %rdi=60 c)%rax=60, %rdi=0
d)%rax=0, %rdi=60, %rsi = Buffer starting address, %rdx=Buffer size

129) For 32-bit signed division on a 32-bt intel processor, .......... instruction is used to
sign-extend 32-bit dividend in %eax register into %edx to make the dividend 64-bit
in %edx:%eax
a) cqto b)cqo c) cltd d)cwtq

130) Given initially %rax=64 & %rbx=196, write the values in the registers %rax &
%rbx after the execution of the following x86-64 assembly language program
segment
xorq %rbx, %rax
xorq %rax, %rbx
xorq %rbx, %rax

a) %rax = 196, %rbx = 64 b) %rax= 64, %rbx = 196

56 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

c) %rax= 260, %rbx= 196 d) %rax=64, %rbx=260

131) For the following 64-bit signed multiplication operation on a 64-bit intel processor,
the 128-bit product result is stored in ............. register pairs.
imulq %rbx
a)%rbx(higher 64-bit):%rax(lower 64-bit) b)%rax(higher 64-bit):%rdx(lower 64-bit)
c)%rax(higher 64-bit):%rbx(lower 64-bit)) d)%rdx(higher 64-bit):%rax(lower 64-bit)

132) For the following 64-bit signed division operation on a 64-bit intel processor, the 64-
bit quotient is stored in .......... register and the 64-bit remainder is stored in ........
idivq %rbx
a)%rdx(remainder), %rax(quotient) b)%rbx(remainder), %rax(quotient)
c)%rax(remainder), %rdx(quotient) d)%rax(remainder), %rbx(quotient)

133) The instruction testq %rbx, %rax performs the following operation:
a)%rax | %rbx b)%rax ^ %rbx c)%rax & %rbx d)%rax - %rbx

134) For 64-bit signed division on a 64-bt intel processor, .......... instruction is used to
sign-extend 64-bit dividend in %rax register into %rdx to make the dividend 128-bit
in %rdx:%rax
a)cwtq b)cqo c)cltd d)cqtd

135) Write the function performed by the following assembly language program
segment:
x in %rdx, y in %rbx, %rax <-- result
cmpq %rbx, %rdx
jle Else
subq %rbx, %rdx
movq %rdx, %rax
jmp Done
Else:
subq %rdx, %rbx
movq %rbx, %rax
Done:
a)x – y b)y – x c)abs(x - y) d)mod(x + y)

136) Write the function performed by the following assembly language program
segment:
x in %rdi, %rax <-- result

movq $0, %rax


Loop:
movq %rdi, %rdx

57 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

andq $1, %rdx


addq %rdx, %rax
shrq %rdi
jne Loop
ret
a)factorial(x) b)square(x) c)power(x) d)Count the number of 1's in x

137) Write the function performed by the following assembly language program
segment:
Registers: n in %rdx, result in %rax

movq $1, %rax


Loop:
imulq %rdx, %rax
subq $1, %rdx
cmpq $1, %rdx
jg Loop
ret
a)square(x) b)power(x) c)factorial(x) d)Count the number of 1's in n

138) The condition checked in ja (jump on above) conditional jump instruction


is ..............
a)~CF&~ZF b)(SF^OF)|ZF c)~(SF^OF)&~ZF d)~(SF^OF)

139) Given a matrix a[R][C] containing elements of type double stored in the computer
main memory in Row-major order where R is the total number of rows and C is the
total number of Columns in the matrix. Choose the correct program segment
containing x86-64 assembly language instructions to compute the address of the location
containing the matrix element a[i][j] where i is the row index & j is the column index.
Given Register Mapping: %rdi  a, %rax  C, %rcx  R, %rsi  j, %rbx  i

a) leaq (%rdi, %rsi, 8), %rsi b) leaq (%rax, 8), %rax


mulq %rbx leaq(%rdi, %rsi, 8) %rsi
leaq(%rax, %rsi, 8), %rax mulq %rax
leaq (%rax, %rsi), %rax

c) leaq (%rdi, %rsi, 8), %rsi d) leaq (%rax, 8), %rax


mulq %rbx leaq (%rax, 8), %rax
leaq (%rsi, %rax, 8), %rax mulq %rbx
leaq (%rbx, %rsi), %rax

140) The condition checked in jg (jump on greater than) conditional jump instruction is .
a)~(SF^OF) b)(SF^OF) c)(SF^OF)|ZF d)~(SF^OF)&~ZF

58 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

141) The condition checked in jge (jump on greater than or equal to) conditional jump
instruction is ..............
a) ~(SF^OF)&~ZF b)(SF^OF) c)~(SF^OF) d)(SF^OF)|ZF

142) The condition checked in jl (jump on less than) conditional jump instruction is ........
a)(SF^OF)|ZF b)(SF^OF) c)~(SF^OF)&~ZF d)~(SF^OF)

143) The condition checked in jle (jump on less than or equal to) conditional jump
instruction is ..............
a)~(SF^OF)&~ZF b)~(SF^OF) c)(SF^OF) d)(SF^OF)|ZF

FILL IN THE BLANKS :

144) Full form of CISC is ..................................................................................................

145) EM64T stands for .......................................................................................................

146) ISA stands for .............................................................................................................

147) IP stands for ...............................................................................................................

148) DI stands for ............................................................................................................

149) Full form of RISC is ...................................................................................................

150) A text file consists of .................... codes representing corresponding text characters.

151) Full form of ASCII .....................................................................................................

152) A hard disk drive consists of collection of …………............. which provide surfaces
that are used to record information.

153) In a ................................memory device, data is retained in the memory as long as


power is applied, once power is removed the data stored gets lost.

154) …......... is a set of conducting wires over which signals are sent and received and are
used to interconnect Processor, Memory and I/O devices

155) Most filesystems place a limit on the length of a filename, typically no more than
…….. characters.

59 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

156) Full form of DMA ……………………………………………………………………...

157) Full form of GNU is ........................................................................................................

158) UNIX is the acronym for ................................................................................................

159) BASH stands for ............................................................................................................

160) In multiprogramming environment, the OS decides which process gets the processor
when and for how much time. This function is called ………….………………….

161) ………………..……………….is the founder of the project GNU.

162) Linux + GNU Utilities = ………………….……….

163) Kernel code executes in a special privileged mode called ……..………… mode with
full access to all resources of the computer

164) ………………….. developed the self-contained Linux kernel from scratch with
the major design goal of UNIX Compatibility.

165) First version of UNIX was created in ………………..…… in 1969.

166) In a ................................................. Operation, data is transferred directly from Hard


disk to Main Memory or Main Memory to hard disk without passing through the
Processor.

167) …..... cache is a Split-cache which has separate Instruction Cache (IC) and a
separate Data Cache(DC).

168) Convert the following Hexadecimal number 0x879CEF to Octal


form. .....................................

169) Determine x in 2^x = 10^38 x= ...........

60 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

170) Determine x in 10^x = 2^1023 x ...........

************************************
END OF PART A
GOTO NEXT PAGE FOR PART B QUESTIONS
************************************

61 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

PART – B
(TOTAL POINTS : 2200)
(QUESTIONS [I] TO [X] – TOTALLY 10 QUESTIONS ON TOPICS
TAUGHT BETWEEN WEEK9 TO WEEK 14)

[I] Library Inter-positioning – You are required to use inter-positioning to


trace the number of calls made to malloc and free functions as the program
runs in order to detect memory leaks in the program and also introduce
code (FIXUP CODE) to remove memory leaks BEFORE EXITING from
the program. 500 POINTS
You are required to write separate wrapper functions for malloc and free to
carry out inter-positioning at
(i) Compile Time
(ii) Link Time

Write a MENU DRIVEN “C” main program to create dynamically a


linked list containing ‘n’ nodes containing information about students
in your class. The linked list must contain atleast 25 nodes (minimum
requirement) or you can have more than 25 nodes.
Each node must contain the following information about a student :
(i) STUDENT FULL NAME (FIRST NAME, MIDDLE
NAME(optional), LAST NAME(surname /family name): 40
characters (minimum)
(ii) STUDENT ID : 10 CHARACTERS (MINIMUM)
(iii) SECTION NO : 6 CHARACTERS (MINIMUM)
(iv) CITY/VILLAGE OF RESIDNT : 20 CHARACTERS
(MINIMUM)
(v) EMAIL ADDRESS: 30 CHARACTERS (MINIMUM)
IN YOUR MENU DRIVEN ‘C’ PROGRAM – PROVIDE THE
FOLLWING MENU OPTIONS IN AN INFINITE LOOP SO THAT
USER CAN SELECT ANY OPTION AND USER CAN
AUTOMATICALLY RETURN TO THIS MENU AFTER

62 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

PERFORMING ANY SELECTED OPERATION AND TO EXIT THE


PROGRAM THE USER HAS TO SELECT THE EXIT OPTION IN
THE MENU
******************************************************************
1 - CREATE A STUDENT LIST
2 - DISPLAY STUDENT LIST
3 - SEARCH USING STUDENT ID
4 - SEARCH USING FIRST NAME/FAMILY NAME/PLACE OF
RESIDENCE
5 - INSERT A NODE
6 - DELETE A NODE
7 - EXIT
******************************************************************
PLEASE ENTER YOUR OPTION : _
After displaying this menu wait for user’s option input which can be any value
between 1 & 7. If the user enters any value less than 1 and greater than 7 – print
appropriate error message “INVALID INPUT???????” and take the user back to
the Menu.
After performing every operation as per the selection made by the user, take the
user back to the same menu. If the user wants to exit this menu, i.e., terminate the
program execution, the user has to select the EXIT option by entering 7 on the
keyboard.
You are required to provide appropriate message “ LIST NOT CREATED ???”
when the user presses any option between 2 & 6 before the list is created.
Write separate ‘C’ functions for the routines to be invoked corresponding to the 7
options given in the Menu. The description of the ‘C’ functions for the routines to
be implemented is given below:

(i) CREATION OF LINKED LIST :The nodes must be created using


malloc function and added to the linked list at run time by reading
information about each student (as given above) from the keyboard
and giving prompt messages to the user to take inputs as given below:
The number of nodes or students ‘n’ is a variable. ‘n’ value must be
read from the keyboard at run time by giving the following prompt
message:
63 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

“ENTER NUMBER OF STUDENTS n =”


After reading the value of n from the user, then ask the user to enter
the information about each student by giving the following prompt
messages for various information about each student to be read from
the keyboard. Repeat this until all the information of ‘n’ students have
been read from the keyboard.
“STUDENT FULL NAME : “
“STUDENT ID : ”
“SECTION NO: “
“CITY/VILLAGE OF RESIDENT : “
“EMAIL ADDRESS : “

(ii) PRINTING LIST OF ‘n’ STUDENT INFORMATION : Write a


‘C’ function to display all the information about ‘n’ students in the list
using a suitable output format as given below.
“STUDENT FULL NAME : “
“STUDENT ID : ”
“SECTION NO: “
“CITY/VILLAGE OF RESIDENT : “
“EMAIL ADDRESS : “

(iii) SEARCH FOR A STUDENT INFORMATION USING


STUDENT ID : Write a ‘C’ function to search for a particular student
information using the STUDENT ID. If search is SUCCESSFUL
then
print “STUDENT INFO FOUND” and then print the complete
information of the student as follows :
“STUDENT FULL NAME : “
“STUDENT ID : ”
“SECTION NO: “
“CITY/VILLAGE OF RESIDENT : “
“EMAIL ADDRESS : “
If search is unsuccessful then print “STUDENT INFO NOT
FOUND”

(iv) SEARCH FOR STUDENT(S) INFORMATION USING FIRST


NAME OR FAMILY NAME OR PLACE OF RESIDENCE :
64 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

Write a ‘C’ function to search for student(s) information using the


FIRST NAME, OR FAMILY NAME(SURNAME) OR PLACE OF
RESIDENCE.
If search is SUCCESSFUL then
print “STUDENT(S) INFO FOUND” and then print the complete
information of the student(s) one after another using the following
output format for each student:
“STUDENT FULL NAME : “
“STUDENT ID : ”
“SECTION NO: “
“CITY/VILLAGE OF RESIDENT : “
“EMAIL ADDRESS : “
Please note that there may be more than one student having the
same FIRST NAME, FAMILY NAME(SURNAME) OR PLACE
OF RESIDENCE. In such cases, print the information of all
students matching the search key.
If search is unsuccessful then print “STUDENT(S) INFO NOT
FOUND”

(v) INSERT A NODE OF STUDENT INFORMATION BEFORE OR


AFTER A NODE HAVING THE STUDENT ID IN THE LIST : Write a
‘C’ function to insert a node of student information before or after a node in
the list having the STUDENT ID specified. The following prompt messages
must be given to the user at run time :
First give the following prompt message to the user -
“ENTER NEW STUDENT INFORMATION :”
Next the read the new student information from the keyboard using the
following prompt messages:
“STUDENT FULL NAME : “
“STUDENT ID : ”
“SECTION NO: “
“CITY/VILLAGE OF RESIDENT : “
“EMAIL ADDRESS : “
After reading the new student information, now ask the following question
to read the ID of the existing student in the list
“WHERE THIS NODE TO BE INSERTED –SPECIFY STUDENT ID
OF EXISTING NODE:”
After taking the student ID then ask next question to know where this node
to be inserted before or after that node by asking the user to enter 0 or 1
65 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

“WANT TO INSERT NEW NODE BEFORE OR AFTER THE


ABOVE NODE – ENTER 0 FOR BEFORE OR 1 FOR AFTER : “
Now display the entire list by invoking the print function in (ii)

You should also consider the case where the user enters the Student ID
which does not exist in the linked list, In that case, the new student
information node must be added at the end of the list. YOU SHOULD
SHOW ALL THESE CASES IN YOUR PROGRAM EXECUTION
OUTPUT.

(vi) DELETE A NODE OF STUDENT INFORMATION USING


STUDENT ID : Write a ‘C’ function to delete a node of student information
using STUDENT ID. Your function must be written in such a way that
before deleting a node you must ask the user whether the user really wants to
delete a node(need confirmation)
“ENTER STUDENT ID OF THE NODE TO BE DELETED :”
After reading the student ID of the node to be deleted, then ask the
confirmation message as follows:
“DO YOU REALLY WANT TO DELETE THIS NODE – CONFIRM
BY PRESSING 1 FOR DELETE OR 0 FOR UNDELETE :”
If the user enters 1 for delete, then delete the node from the list and then give
the message “NODE DELETE SUCCESSFUL “
If the user enters 0 for undelete, then do not perform any delete operation by
giving the message “NODE DELETE IGNORED “
Now display the entire list by invoking the print function in (ii)

(vii) EXIT – TO EXIT FROM THE PROGRAM : write a ‘C’ function to exit
from the program. This is an important step in your program where you
need to check and perform the following operations to detect memory
leak problem and to resolve the memory leak problem by calling a
fixup routine to deallocate the nodes which are not yet deallocated
using free function before exiting the main program.

Let ‘n’ be the total number of calls made to the malloc() function to
add/insert nodes to the list.
Let ‘m’ be the number of calls made to the free function to delete nodes
from the list.
Now you need to consider the following two cases :
66 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

Case 1 : if n > m then THERE IS MEMORY LEAK


Hence. print the message that “MEMORY LEAK IS
DETECTED”
Then display the number of blocks (count) not yet deallocated and
also print the list of starting addresses of the memory areas not
yet deallocated. After that call the fixup routine to free the not yet
deallocated memory areas by giving the message “NOW
FREEING NOT YET DELLOCATED BLOCKS
………………..” (here the number of dots can be equal to the
number of blocks deallocated – as you free a block display a dot)
Once you finish freeing all the blocks then give the message
“MEMORY LEAK IS TOTALLY REMOVED !!!!!!!” and
then exit from the program.
Case 2 : If n = m then THERE IS NO MEMORY LEAK
Hence. print the message that “ NO MEMORY LEAK
DETECTED” and then exit from the program.
YOU NEED TO RUN THE SAME PROGRAM TWICE TO
SHOW THE ABOVE TWO CASES BY TAKING INPUT STUDENT
LIST CONTAINING ATLEAST 25 NODES (OR MORE – WHICH
IS PREFERRABLE) EACH TIME.

PLEASE NOTE THAT SEPARATE PROGRAMS MUST BE


WRITTEN FIRST TO CARRY OUT LIBRARY
INTERPOSITIONING AT COMPILE TIME AND NEXT TO
CARRY OUT LIBRAY INTERPOSITIONING AT LINK TIME.

IN BOTH THE CASES, YOUR MAIN PROGRAM AND SUB


FUNCTIONS WILL REMAIN THE SAME, BUT THE WRAPPER
FUNCTIONS FOR malloc and free WILL BE DIFFERENT.

67 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE ENTIRE PROGRAM


ENTERED ON YOUR LAPTOP. SCREENSHOTS SHOULD BE
CLEAR, READABLE AND HAVING BIGGER FONTS
(REGULAR & READABLE FONTS FOR EVALUATION
OTHERWISE GRADE O WILL BE GIVEN):

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

68 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

69 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT] SCREENSHOTS OF THE COMMAND ENTERD AND


INPUTS GIVEN ON YOUR LAPTOP AND SCREENSHOTS OF
THE RESULTS OBTAINED ON YOUR LAPTOP.
SCREENSHOTS SHOULD BE CLEAR, READABLE AND
HAVING BIGGER FONTS (REGULAR & READABLE FONTS
FOR EVALUATION OTHERWISE GRADE O WILL BE
GIVEN):

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

70 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

71 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[II] Consider Virtual Address to Physical address translation on a small


system with a TLB and L1 D-cache with the following assumptions:
600
POINTS
The memory is byte addressable.
Virtual addresses (VA) are 24 bits wide.
Physical addresses (PA) are 20 bits wide.
The page size is 4KB.
The TLB is four-way set associative with 32 total entries.
The L1 D-cache is physically addressed and four-way associative
mapped, with a 4-byte line (block)size and 32 total blocks. Cache block
is byte addressable.
FOR THIS QUESTION, ALL ANSWERS MUST BE WRITTEN,
THAT IS, TYPED IN THE SPACE SHOWN BY …….. AGAINST
EACH PART.

(i) First Compute VPN bits = ……….. bits & VPO bits = …………… bits

VA

(ii) TLB is four-way set associative with 32 total entries.

Compute TLBI length= …………bits, TLBT = ………….. bits

Set Valid Tag PPN Valid Tag PPN Valid Tag PPN Valid Tag PPN

0 0 13D 0C 0 9AB 00 0 000 00 1 17C 2F

1 1 03B 1A 1 245 19 1 423 16 0 1A7 0A

2 0 246 2D 0 812 7D 1 091 2A 0 1B8 09

3 1 14F 1C 1 1D3 1E 1 1A9 1C 1 12F 13

4 0 D23 3F 0 765 54 0 0CD 0D 1 177 4E

5 1 846 1A 1 139 6C 1 465 67 0 1A0 08

6 0 EED 00 0 828 00 0 1BD CB 0 1BF 3A

7 1 179 1C 1 3C9 1E 1 1A9 4E 1 12F 2C

72 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

(iii) Page Table (PT) in memory


Compute Total Number of entries in Page Table = …………….. entries
SOME ENTRIES OF THE PAGE TABLE ARE GIVEN BELOW
VPN Valid PPN VPN Vali PPN VPN Valid PPN VPN Valid PPN
d
1C0 1 C8 1C8 1 73 1D0 1 43 1D8 1 32
1C1 0 23 1C9 0 89 1D1 1 C5 1D9 0 87
1C2 1 3D 1CA 0 AC 1D2 0 0B 1DA 1 C9
1C3 1 27 1CB 0 BF 1D3 1 78 1DB 1 B5
1C4 0 0D 1CC 0 DE 1D4 0 8D 1DC 0 0D
1C5 1 67 1CD 1 C5 1D5 0 0C 1DD 1 D7
1C6 1 CE 1CE 1 9F 1D6 1 34 1DE 0 1B
1C7 0 09 1CF 1 67 1D7 1 2F 1DF 1 CE

VPN Valid PPN VPN Vali PPN VPN Valid PPN VPN Valid PPN
d
480 1 8C 488 1 7C 640 1 38 648 1 2F
481 0 09 489 0 0C 641 1 5A 649 1 78
482 1 3C 48A 1 2A 642 0 94 64A 0 59
483 1 2E 48B 0 0D 643 1 8C 64B 1 CB
484 0 05 48C 0 2E 644 0 D9 64C 0 F0
485 1 68 48D 1 35 645 0 6C 64D 1 CD
486 1 E3 48E 1 F4 646 1 3E 64E 1 1E
487 0 06 48F 1 C6 647 1 2F 64F 1 4B

VPN Valid PPN VPN Vali PPN VPN Valid PPN VPN Valid PPN
d
9C0 1 38 9C8 1 7D AF0 1 D3 AF8 1 F2
9C1 0 9D 9C9 0 D2 AF1 1 35 AF9 1 67
9C2 1 3E 9CA 0 E2 AF2 0 E0 AFA 0 89
9C3 1 52 9CB 0 8C AF3 1 87 AFB 1 8D
9C4 0 0F 9CC 0 7D AF4 0 4D AFC 0 05
9C5 1 67 9CD 1 6C AF5 0 8F AFD 1 D2
9C6 1 E8 9CE 1 F2 AF6 1 38 AFE 1 1A
9C7 0 F0 9CF 1 67 AF7 1 2F AFF 1 CC

VPN Valid PPN VPN Vali PPN VPN Valid PPN VPN Valid PPN
d
DE0 1 9C DE8 1 89 DF0 1 33 DF8 1 2D
DE1 0 6D DE9 0 FF DF1 1 55 DF9 1 47
DE2 1 37 DEA 0 EE DF2 0 66 DFA 1 9F
DE3 1 62 DEB 0 DD DF3 1 88 DFB 1 BB
DE4 0 09 DEC 0 CC DF4 0 DD DFC 0 0F
DE5 1 6F DED 1 56 DF5 0 0F DFD 1 3D
DE6 1 5E DEE 1 FA DF6 1 3C DFE 1 91

73 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

DE7 0 7D DEF 1 6E DF7 1 2F DFF 1 DC

(iv) L1 D-Cache is four-way set associative with 32 blocks with each block of size 4
bytes.

PA = ……………bits

CO = …………. bits, CI= …………….bits, CT=……………..bits

S V Tag Block V Tag Block V Tag Block V Tag Block


e
t B0 B1 B2 B3 B0 B1 B2 B3 B0 B1 B2 B3 B0 B1 B2 B3

0 1 263C 48 56 35 12 1 57E9 A8 76 34 72 1 7D69 D9 E6 C5 B2 0 0508 7E 6C 8F 9A

1 0 E160 90 62 94 23 1 1542 3B 87 56 67 1 C067 E8 D6 E4 A3 1 C198 A4 B4 DC 42

2 0 0687 18 36 84 46 1 1D07 4C 87 76 82 1 3002 E9 6C D5 92 0 D074 F2 E6 E2 D9

3 0 C184 81 64 93 72 0 268D 5F 64 88 FD 1 313C AB D8 C3 EF 1 25F7 D7 E9 C7 EA

4 1 E263 45 86 95 34 1 B210 49 84 A4 78 1 A150 9D 6E 5C 2C 0 0507 E2 F8 D6 A8

5 0 D160 98 43 84 38 3DF0 7C 86 A1 93 0 B067 FE CD AB 89 1 198C FF CC DD 99

6 0 A068 73 67 64 93 1 C1D0 98 76 45 32 1 3624 F9 DC EF D2 0 0749 A9 8B 3D EF

7 0 1849 28 76 14 43 0 268C A8 46 44 55 1 303C BA 8D 3F EE 1 140E C4 76 41 02

CASE 1: Processor generates a virtual address VA = 0x 1DEC84


Translate this to physical address PA using TLB or Page Table
VA = 0x…………………
VA

Compute :

VPN : 0x…………… VPO : 0x…………..

TLBI : 0x…………... TLBT : 0x…………..

TLB Hit?: ………….... (Y/N) Page Fault?: ……….. (Y/N)

PPN : 0x……….…
74 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

Page Table access Required? : ………….. (Y/N)

PA = 0x………………….
PA

Compute :

CO : 0x……….. CI : 0x………….. CT : 0x…………..

Cache Hit? : …………………..(Y/N)

Cache Byte accessed : 0x………

Main Memory access Required?: …………. (Y/N)

CASE 2 : Processor generates a virtual address VA = 0x48A846,


Translate this to physical address PA using TLB or Page Table

VA = 0x…………………
VA

Compute :

VPN : 0x…………… VPO : 0x…………..

TLBI : 0x…………... TLBT : 0x…………..

TLB Hit?: ………….... (Y/N) Page Fault?: ……….. (Y/N)

PPN : 0x……….…

Page Table access Required? : ………….. (Y/N)

75 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

PA = 0x………………….
PA

Compute :

CO : 0x……….. CI : 0x………….. CT : 0x…………..

Cache Hit? : …………………..(Y/N)

Cache Byte accessed : 0x………

Main Memory access Required?: …………. (Y/N)

CASE 3: Processor generates a virtual address VA = 0x64FEED


Translate this to physical address PA using TLB or Page Table

VA = 0x…………………
VA

Compute :

VPN : 0x…………… VPO : 0x…………..

TLBI : 0x…………... TLBT : 0x…………..

TLB Hit?: ………….... (Y/N) Page Fault?: ……….. (Y/N)

PPN : 0x……….…

Page Table access Required? : ………….. (Y/N)

76 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

PA = 0x………………….
PA

Compute :

CO : 0x……….. CI : 0x………….. CT : 0x…………..

Cache Hit? : …………………..(Y/N)

Cache Byte accessed : 0x………

Main Memory access Required?: …………. (Y/N)

CASE 4: Processor generates a virtual address VA = 0x9CD49A


Translate this to physical address PA using TLB or Page Table

VA = 0x…………………
VA

Compute :

VPN : 0x…………… VPO : 0x…………..

TLBI : 0x…………... TLBT : 0x…………..

TLB Hit?: ………….... (Y/N) Page Fault?: ……….. (Y/N)

PPN : 0x……….…

Page Table access Required? : ………….. (Y/N)

77 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

PA = 0x………………….
PA

Compute :

CO : 0x……….. CI : 0x………….. CT : 0x…………..

Cache Hit? : …………………..(Y/N)

Cache Byte accessed : 0x………

Main Memory access Required?: …………. (Y/N)

CASE 5: Processor generates a virtual address VA = 0xAFB87C


Translate this to physical address PA using TLB or Page Table

VA = 0x…………………
VA

Compute :

VPN : 0x…………… VPO : 0x…………..

TLBI : 0x…………... TLBT : 0x…………..

TLB Hit?: ………….... (Y/N) Page Fault?: ……….. (Y/N)

PPN : 0x……….…

Page Table access Required? : ………….. (Y/N)

78 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

PA = 0x………………….
PA

Compute :

CO : 0x……….. CI : 0x………….. CT : 0x…………..

Cache Hit? : …………………..(Y/N)

Cache Byte accessed : 0x………

Main Memory access Required ?: …………. (Y/N)

CASE 6: Processor generates a virtual address VA = 0xDEED23


Translate this to physical address PA using TLB or Page Table

VA = 0x…………………
VA

Compute :

VPN : 0x…………… VPO : 0x…………..

TLBI : 0x…………... TLBT : 0x…………..

TLB Hit?: ………….... (Y/N) Page Fault?: ……….. (Y/N)

PPN : 0x……….…

Page Table access Required? : ………….. (Y/N)

PA = 0x………………….
79 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

PA

Compute :

CO : 0x……….. CI : 0x………….. CT : 0x…………..

Cache Hit? : …………………..(Y/N)

Cache Byte accessed : 0x………

Main Memory access Required ?:…………. (Y/N)

[III] You are required to go through the following program and do the
following: 200 POINTS
80 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

int main()
{
i=0;
printf(“Parent %d :SP FINAL ASSIGNMENT – 16TH WEEK - PURPOSE”, i);
if (fork()==0)
printf(“Child %d : INTRODUCED TO IMPROVE OVERALL GRADE ”, ++i);
if (fork()==0)
printf(“Child %d : FOR RETAKERS TO REPLACE THE MISSED LAB ”, ++i);
if (fork()==0)
printf(“Child %d : NEED TO PUT MORE EFFORTS ”, ++i);
if (fork()==0)
printf(“Child %d :NEED TO FLY HIGH TO REACH THE TOP”, ++i);
printf(“STUDY VERY HARD…….GOOD LUCK\n”);
exit(0);
}

a) Draw the corresponding Process Graph for the program clearly


showing the parent and child processes execution from creation to
termination
YOU ARE REQUIRED TO DRAW THE FIGURE BY HAND, THEN
SCAN AND INSERT HERE.
EVERY PAGE OF THE HANDWRITTEN ANSWER SHEET MUST BEGIN
WITH STUDENT NAME, STUDENT ID, SECTION NO. AND STUDENT
SIGNATURE.

81 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

b) Run this program on your laptop and provide all the outputs of the
parent and child processes and provide your analysis on these outputs.
82 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE ENTIRE PROGRAM


ENTERED ON YOUR LAPTOP. SCREENSHOTS SHOULD BE
CLEAR, READABLE AND HAVING BIGGER FONTS
(REGULAR & READABLE FONTS FOR EVALUATION
OTHERWISE GRADE O WILL BE GIVEN).

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

83 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE COMMAND


ENTERED AND INPUTS GIVEN ON YOUR LAPTOP AND
SCREENSHOTS OF THE RESULTS OBTAINED ON YOUR
LAPTOP. SCREENSHOTS SHOULD BE CLEAR, READABLE
AND HAVING BIGGER FONTS (REGULAR & READABLE
FONTS FOR EVALUATION OTHERWISE GRADE O WILL BE
GIVEN).

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

84 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

85 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[IV] You are required to go through the following program and do the
following: 200 POINTS

int main()
{
pid_t pid;
printf("SYSTEMS PROGRAMMING ”);
if (fork() = 0 )
{
printf(“SCORED LOW OR HIGH IN MIDTERM EXAM”);
if (fork() != 0)
printf("DOING FINAL ASSIGNMENT”);
}
if (fork() !=0)
{
printf(“SCORED LOW OR HIGH IN FINAL EXAM”);
if (fork() == 0)
printf("TRYING TO FINISH FINAL ASSIGNMENT FULLY”);
}
printf(“GRADING : DONE VERY WELL IN ALL – EXPECTING A+ GRADE \n“);
}

a) Draw the corresponding Process Graph for the program clearly showing
the parent and child processes execution from creation to termination
YOU ARE REQUIRED TO DRAW THE FIGURE BY HAND, THEN
SCAN AND INSERT HERE.
EVERY PAGE OF THE HANDWRITTEN ANSWER SHEET MUST BEGIN
WITH STUDENT NAME, STUDENT ID, SECTION NO. AND STUDENT
SIGNATURE.

86 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

87 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

b) Run this program on your laptop and provide all the outputs of the
parent and child processes and provide your analysis on these outputs.
[INSERT HERE] SCREENSHOTS OF THE ENTIRE PROGRAM
ENTERED ON YOUR LAPTOP. SCREENSHOTS SHOULD BE
CLEAR, READABLE AND HAVING BIGGER FONTS
(REGULAR & READABLE FONTS FOR EVALUATION
OTHERWISE GRADE O WILL BE GIVEN):

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

88 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

89 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE COMMAND


ENTERED AND INPUTS GIVEN ON YOUR LAPTOP AND
SCREENSHOTS OF THE RESULTS OBTAINED ON YOUR
LAPTOP. SCREENSHOTS SHOULD BE CLEAR, READABLE
AND HAVING BIGGER FONTS (REGULAR & READABLE
FONTS FOR EVALUATION OTHERWISE GRADE O WILL BE
GIVEN).

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

90 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

91 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[V] Consider the following program wrongcnt.c showing improper


synchronization between two threads (thread1, thread2) when accessing
the global variable cnt in their corresponding thread function.
200 POINTS

/* PROGRAM wrongcnt.c */
volatile long cnt = 0;

int main(int argc, char **argv)


{
long niters;
pthread_t tid1, tid2;

niters = atoi(argv[1]);
pthread_create(&tid1, NULL, thread, &niters);
pthread_create(&tid2, NULL, thread, &niters);
pthread_join(tid1, NULL);
pthread_join(tid2, NULL);

if (cnt != (2 * niters))
printf("BOOM! cnt=%ld\n", cnt);
else
printf("OK cnt=%ld\n", cnt);
exit(0);
}

void *thread(void *vargp)


{
long i, niters = *((long *)vargp);

for (i = 0; i < niters; i++)


cnt++;

return NULL;
}

92 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

a) Run the program wrongcnt.c using the command $./worngcnt 50000


where 50000 is the number of iterations specified as command line argument.
Identify the thread synchronization problem (shared variable involved) for get-
ting different answers at different runs.

[INSERT HERE] SCREENSHOTS OF THE ENTIRE PROGRAM


ENTERED ON YOUR LAPTOP. SCREENSHOTS SHOULD BE
CLEAR, READABLE AND HAVING BIGGER FONTS
(REGULAR & READABLE FONTS FOR EVALUATION
OTHERWISE GRADE O WILL BE GIVEN).

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

93 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

94 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE COMMAND


ENTERD AND INPUTS GIVEN ON YOUR LAPTOP and
SCREENSHOTS OF THE RESULTS OBTAINED ON YOUR
LAPTOP. SCREENSHOTS SHOULD BE CLEAR, READABLE
AND HAVING BIGGER FONTS (REGULAR & READABLE
FONTS FOR EVALUATION OTHERWISE GRADE O WILL BE
GIVEN):

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

95 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

96 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

b) Write the corresponding assembly code for the counter loop in thread i . Label
the Head and Tail instruction blocks as Hi and Ti respectively. Label the three
instructions in the critical section as Li, Ui, Si

C code for counter loop in thread i


for (i = 0; i < niters; i++)
cnt++;

c) Write the assembly language instructions in the critical Section

97 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

d) Draw a Progress Graph and do the following :


(i) Show the concurrent execution of the assembly code corresponding to the
loop executed concurrently by the threads thread1 and thread2.
(ii) Identify the critical region and the assembly language instructions in that
region
(iii) Draw the unsafe region in progress graph.
YOU ARE REQUIRED TO DRAW THE FIGURE BY HAND, THEN SCAN
AND INSERT HERE.
CUT & PASTE OF THE FIGURES FROM THE TEXT BOOKS, LECTURE
SLIDES AND OTHER AVAILABLE MATERIALS ON THE INTERNET IS
TOTALLY PROHIBITED. IF FOUND – WILL BE GIVEN GRADE 0
WITHOUT GOING THROUGH ANY PART OF THIS QUESTION. ONLY
HANDWRITTEN SOLUTION/FIGURE IS ACCEPTED
EVERY PAGE OF THE HANDWRITTEN ANSWER SHEET MUST BEGIN
WITH STUDENT NAME, STUDENT ID, SECTION NO. AND STUDENT
SIGNATURE.

98 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

e) Show atleast SIX Safe Trajectories in the progress graph which lead to
proper thread synchronization.

f) Show atleast SIX Unsafe Trajectories in the progress graph which lead to
improper thread synchronization.

99 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

g) Rewrite the thread function using semaphores P(&mutex) and V(&mutex) to


control access to cnt shared variable to provide proper synchronization.
Modify the above program (call it correctcntn.c ) using semaphores to
provide proper synchronization to control access to cnt shared variable.
Run the program correctcnt.c using the command $./correctcnt 50000
where 50000 is the number of iterations specified as command line
arguments. Identify the thread synchronization provided by the semaphore
as different runs of the program, i.e., $./correctcnt 50000 result in the
same answer.
[INSERT HERE] SCREENSHOTS OF THE MODIFIED
PROGRAM ENTERED ON YOUR LAPTOP. SCREENSHOTS
SHOULD BE CLEAR, READABLE AND HAVING BIGGER
FONTS (REGULAR & READABLE FONTS FOR EVALUATION
OTHERWISE GRADE O WILL BE GIVEN):

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

100 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

101 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE COMMAND


ENTERD AND INPUTS GIVEN ON YOUR LAPTOP and
SCREENSHOTS OF THE RESULTS OBTAINED ON YOUR
LAPTOP. SCREENSHOTS SHOULD BE CLEAR, READABLE
AND HAVING BIGGER FONTS (REGULAR & READABLE
FONTS FOR EVALUATION OTHERWISE GRADE O WILL BE
GIVEN):

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

102 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

103 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[VI] Write a shell program that supports job control. Your shell prompt
should be as follows : <your name>, for example, if your name is aziz
then your shell prompt should be <aziz> 200
POINTS
Your shell should have the following features:
 The command line typed by the user consists of a name and zero or
more arguments, all separated by one or more spaces.
 If name is a built-in-linux-command, the shell handles it immediately
and waits for the next command line.
 Otherwise, the shell assumes that name is an executable file, which it
loads and runs in the context of an initial child process (job).
 The process group ID for the job is identical to the PID of the child.
 Each job is identified by either a process ID (PID) or a job ID (JID),
which is a small arbitrary positive integer assigned by the shell.
 JIDs are denoted on the command line by the prefix ‘%’.
 For example,“%5” denotes JID 5, and “5” denotes PID 5.
 If the command line ends with an ampersand, then the shell runs the
job in the background.
 Otherwise, the shell runs the job in the foreground.
 Typing ctrl-c (ctrl-z) causes the shell to send a SIGINT(SIGTSTP)
signal to every process in the foreground process group.
 The jobs built-in command lists all background jobs.
 The bg <job> built-in command restarts <job> by sending it a SIG-
CONT signal, and then runs it in the background.
 The <job> argument can be either a PID or a JID.
 The fg <job> built-in command restarts <job> by sending it a SIG-
CONT signal, and then runs it in the foreground.
 The shell reaps all of its zombie children.
 If any job terminates because it receives a signal that was not caught,
then the shell prints a message to the terminal with the job’s PID and a
description of the offending signal.

104 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

A Sample Shell Session for this Question is given below :


Sample Shell Session for the Question
$ ./shellcmd Run your shell program
<aziz> prog1
prog1: Command not found Execve can’t find executable
<aziz> gcc –o strman strman.c
<aziz> ./strman 10
Job 5035 terminated by signal: Interrupt User types ctrl-c
<aziz> strman 100 &
[1] 5036 strman 100 &
<aziz> strman 200 &
[2] 5037 strman 200 &
<aziz> jobs
[1] 5036 Running strman 100 &
[2] 5037 Running strman 200 &
<aziz> fg %1
Job [1] 5036 stopped by signal: Stopped User types ctrl-z
<aziz> jobs
[1] 5036 Stopped strman 100 &
[2] 5037 Running strman 200 &
<aziz> bg 5035
5035: No such process
<aziz> bg 5036
[1] 5036 strman 100 &
<aziz> /bin/kill 5036
Job 5036 terminated by signal: Terminated
<aziz> fg %2 Wait for fg job to fin-
ish.
<aziz> /bin/ls –la
<aziz>/bin/ps -la
<aziz>/bin/ps w
<aziz> quit
$ Back to the Unix shell

105 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE PROGRAM


ENTERED ON YOUR LAPTOP. SCREENSHOTS SHOULD BE
CLEAR, READABLE AND HAVING BIGGER FONTS
(REGULAR & READABLE FONTS FOR EVALUATION
OTHERWISE GRADE O WILL BE GIVEN):

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

106 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[INSERT HERE] SCREENSHOTS OF THE COMMAND


ENTERD AND INPUTS GIVEN ON YOUR LAPTOP and
107 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

SCREENSHOTS OF THE RESULTS OBTAINED ON YOUR


LAPTOP. SCREENSHOTS SHOULD BE CLEAR, READABLE
AND HAVING BIGGER FONTS (REGULAR & READABLE
FONTS FOR EVALUATION OTHERWISE GRADE O WILL BE
GIVEN):

BEFORE ENTERING ANY COMMAND ON LINUX YOU MUST


ENTER THE FOLLOWING COMMAND :
$PS1=”\d \t \u@\h \#\$”
TO CHANGE YOUR SHELL PROMPT TO KNOW YOUR
EXECUTION DETAILS ON YOUR LAPTOP.
ALL COMMANDS ENTERED MUST HAVE THIS PROMPT
WHICH IS A PROOF THAT YOU HAVE EXECUTED THE
COMMANDS AND PROGRAMS ON YOUR LAPTOP.
OTHERWISE YOU WILL GET A GRADE 0.

108 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[VII] WRITE THE ANSWER IN THE BOX PROVIDED AGAINST EACH


OF THE MULTIPLE CHOICE QUESTIONS 100 POINTS

109 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

READ THE QUESTIONS CAREFULLY AND CORRECTLY.


FOR THIS QUESTION, ANSWER MUST BE WRIITEN, THAT IS,
TYPED IN THE BOX PROVIDED AGAINST EACH QUESTION IN
THIS PART ONLY
1. ELF stands for …………………………………
a) Electrically & Loadable Format
b) Executable & Loadable Format
c) Electrically & Linkable Format
d) Executable & Linkable Format

2. Local variables are maintained at run time on ………..


a) Heap b) stack c) registers d) kernel area

3. The extension of object files that contain code and data that are loaded and
linked into an application dynamically, at either load-time or run-time

a) .ldl b) .o c) .so d) .exe

4. Identify the strong symbols in the following program.


extern int buf[];
int *bufp0 = &buf[0];
int *bufp1;

void swap() {
int temp;
bufp1 = &buf[1];
temp = *bufp0;
*bufp0 = *bufp1;
*bufp1 = temp;
}
a) buf, bufp0, bufp1 b) buf, bufp0, swap c) bufp0, swap, temp d) bufp0, swap

5. Two main tasks performed by the linker to build executable code are
…………………………………
a) Compiling & Linking
b) Assembling & Linking
c) Symbol Resolution & Relocation
d) Resolution & Loading

6. In which section of the ELF Relocatable object file, the uninitialized global and static C
variables are specified.
a) .text b) .data c) .rodata d) .bss

110 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

7. Symbols that are defined and referenced exclusively by module m are ……………….
a) Global symbols b) External symbols c) Local symbols d) Strong symbols

8. The dynamic Linker interface function used to load and link the shared library
filename at run time is ……………….
a) dlsym b) dlopen c) dllink d) dllib

9. …………………… function is used on the Linux/Unix system to invoke the loader to load the
executable into memory and execute.
a) ld b) fork c) execve d) ld-linux.so

10. Static linker tool used on linux system is ..…………………….


a) ld b) fork c) execve d) ld-linux.so

11. Dynamic linker tool used on linux system …………………….


a) ld b) fork c) execve d) ld-linux.so

12. The three special pseudo sections that don’t have entries in the section header table in
ELF object file are ……………………………………………….……….
a) BSS, COMMON, RODATA
b) BSS, SYMTAB, COMMON
c) ABS, UNDEF, COMMON
d) ABS, BSS, UNDEF

13. A powerful linking technique that allows programmers to intercept calls to shared
library functions and execute their own code instead is called ………………..

a) dynamic linking b) static linking


c) library Inter-positioning d) load-time linking

14. A Static RAM(SRAM) 1-bit storage cell uses …………….. Transistors(s) & …………..
capacitor
a) 4 & 0 b) 1 & 1 c) 6 & 1 d) 6 & 0

15. A Dynamic RAM (DRAM 1-bit storage cell uses …………….. Transistors(s) &
………….. capacitor
a) 4 & 0 b) 1 & 1 c) 6 & 1 d) 6 & 0

16. State one similarity between SRAM & DRAM semiconductor devices.
…………………………………….……….
a) Both are Electrically Erasable Programmable Read Only Memory devices

111 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

b) Both use capacitors to store the data


c) Both are Non-volatile devices
d) Both are Volatile devices

17. Flash memory is a kind of …………………………………………………………………


a) EEPROM with byte-erasure capability
b) EEPROM with block-erasure capability
c) EPROM with read-write capability
d) Volatile device with read-write capability

18. Consider the following code generated by the assembler :


00000000<main>:
Byte offset Machine instruction Assembly language instruction
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 ec 08 sub $0x8,%esp
6: e8 00 00 00 00 call swap
7: R_X86_64_PC32 swap -0x4
b: 31 c0 xor %eax,%eax
d: 89 ec mov %ebp,%esp
f: 5d pop %ebp
10: c3 ret
00000018<swap>:
18: 55 push %ebp
……….. …………… ………………..
Assume that the linker has determined the run-time addresses for the .text section.
Runtime memory address allocated to .text section is 0x80004000. Also assume that the
main code is placed at the beginning of .text section immediately followed by the swap
section as shown in the code above. You are required to perform the second step of
Relocation phase of linking process to relocate the instruction in the code below by
assigning the run-time memory addresses and resolve the references at the byte offset 6
and replace 00 00 00 00 by one of the appropriate values/run-time addresses given
below.
a) 00 00 00 0c b) 0c 00 00 00
c) 00 00 00 0d d) 0d 00 00 00

19. What is the capacity of a disk with six platters, 20,000 cylinders, an average of 8000
sectors per track and 512 bytes per sector
a) 889.04GB b) 923.08GB c) 983.04GB d) 989.08GB

20. The time required to move the arm assembly from the current position to the required
track is called ………………………………….
a) transfer time b) rotational latency c) seek time d) access time

112 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

21. The waiting time required for first bit of the target sector to pass under the read/write
head after positioning the head over the required track is called
………………………………….
a) transfer time b) rotational latency c) seek time d) access time

22. The time required for reading from/or writing to a sector once the read/write head
encounters the first bit of the target sector is called ………………………………….
a) transfer time b) rotational latency c) seek time d) access time

23. Given a disk drive with the following parameters:


Rotational Rate =15,000 RPM, Average Seek Time = 9ms,
Average number of sectors/track = 800
Determine the average access time ………………………………ms
a) 12.005 b) 11.005 c) 13.005 d) 15.005

24. ……………………………………………………………….performs the mapping between logical disk


blocks and actual physical sectors.
a) DRAM Memory controller b) Hard disk controller
c) Keyborad controller d) Graphics Adapter

25. A………………………………………. package consists of one or more flash memory


chips, which replace the mechanical drive in a conventional rotating disk, and a flash
translation layer, which is a hardware/firmware device that plays the same role as a
disk controller, translating requests for logical blocks into accesses of the underlying
physical device.
a) Magnetic disk b) Magnetic Tape
c) CDROM disk d) Solid State Disk

26. A Direct Mapped Cache has ………………………………………………………. & each set has
……………………………… .
a) ONE SET, ONE BLOCK/LINE
b) ONE SET, MORE THAN ONE BLOCK/LINE
c) MORE THAN ONE SET, ONE BLOCK/LINE
d) MORE THAN ONE SET, MORE THAN ONE BLOCK/LINE

27. A Fully Associative Mapped Cache has ………………………………………………………. & each set has
……………………………… .
a) ONE SET, ONE BLOCK/LINE
b) ONE SET, MORE THAN ONE BLOCK/LINE
c) MORE THAN ONE SET, ONE BLOCK/LINE
d) MORE THAN ONE SET, MORE THAN ONE BLOCK/LINE

28. A Set Associative Cache has ………………………………………………………. & each set has
……………………………… .
a) ONE SET, ONE BLOCK/LINE

113 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

b) ONE SET, MORE THAN ONE BLOCK/LINE


c) MORE THAN ONE SET, ONE BLOCK/LINE
d) MORE THAN ONE SET, MORE THAN ONE BLOCK/LINE

29. Consider a 32-bit microprocessor that has an on-chip 64-KB direct mapped cache.
Assume that the cache has a line (block) size of 4 words where each word is 32-bits (4
bytes). Determine the number of bits in TAG, INDEX, BYTE OFFSET fields in the
memory address.
a) TAG=18 bits, INDEX=10 bits, BYTE OFFSET=4 bits
b) TAG=20 bits, INDEX=6 bits, BYTE OFFSET=6 bits
c) TAG=16bits, INDEX=10bits, BYTE OFFSET=6 bits
d) TAG=16bits, INDEX=12bits, BYTE OFFSET=4 bits

30. Consider a 32-bit microprocessor that has an on-chip 64-KB direct mapped cache.
Assume that the cache has a line (block) size of 4 words where each word is 32-bits (4
bytes). Where in the cache is the word from memory location 79D5C789 mapped?

a) TAG=0x1E757, INDEX=0x078, BYTE OFFSET=0x09


b) TAG=0x79D5C, INDEX=0x1E bits, BYTE OFFSET=0x09
c) TAG=0x79D5, INDEX=0xC78, BYTE OFFSET=0x09
d) TAG=0x79D5, INDEX=0x078, BYTE OFFSET=0x09

31. Consider a 32-bit microprocessor that has an on-chip 64-KB Fully Associative mapped
cache. Assume that the cache has a line (block) size of 4 words where each word is 32-
bits (4 bytes). Determine the number of bits in TAG & BYTE OFFSET fields in the
memory address.
a) TAG=20 bits, BYTE OFFSET=12 bits
b) TAG=22 bits, BYTE OFFSET=10 bits
c) TAG=24bits, BYTE OFFSET=8 bits
d) TAG=28bits, BYTE OFFSET=4 bits

32. Consider a 32-bit microprocessor that has an on-chip 64-KB Fully Associative mapped
cache. Assume that the cache has a line (block) size of 4 words where each word is 32-
bits (4 bytes). Where in the cache is the word from memory location A8B7C6D5
mapped?

a) TAG=0xA8B7C6D, BYTE OFFSET=0x05


b) TAG=0xA8B7C6, BYTE OFFSET=0xD5
c) TAG=0xA8B7C, BYTE OFFSET=0x6D5
d) TAG=0xA8B7, BYTE OFFSET=0xC6D5

33. Consider a 32-bit microprocessor that has an on-chip 64-KB 8-way Set-Associative
mapped cache. Assume that the cache has a line (block) size of 16 words where each

114 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

word is 32-bits (4 bytes). Determine the number of bits in TAG, SET, BYTE OFFSET
fields in the memory address.
a) TAG=18 bits, SET=10 bits, BYTE OFFSET=4 bits
b) TAG=19 bits, SET=7 bits, BYTE OFFSET=6 bits
c) TAG=20 bits, SET=8bits, BYTE OFFSET=4 bits
d) TAG=19 bits, SET=9 bits, BYTE OFFSET=4 bits

34. Consider a 32-bit microprocessor that has an on-chip 64-KB direct mapped cache.
Assume that the cache has a line (block) size of 4 words where each word is 32-bits (4
bytes). Where in the cache is the word from memory location FEEDBAC8 mapped?

a) TAG=0x3FBB6, SET=0x3AC, BYTE OFFSET=0x08


b) TAG=0xFEEDB, SET=0xAC, BYTE OFFSET=0x08
c) TAG=0x7F76D, SET=0x6B, BYTE OFFSET=0x08
d) TAG=0x7F76D SET=0x1AC, BYTE OFFSET=0x08

35. In ………..………….…., every write operation to the cache is repeated to the main
memory at the same time
a) Write-back b) Write-through
c) Allocate on write d) Non-Allocate on write

36. In ………..………….…., all writes are made only to the cache and write to the main
memory is postponed until a replacement is needed.

a) Write-back b) Write-through
c) Allocate on write d) Non-Allocate on write

37. ……………………………………………policy uses Non-Allocate on write upon a


cache miss.
a) Write-back b) Write-through
c) Allocate on write d) Non-Allocate on write

38. ………………………..…………. policy uses Allocate on write upon a cache miss.


a) Write-back b) Write-through
c) Allocate on write d) Non-Allocate on write

39. If the required word is found in the cache then it is termed as …………..
a) Page Hit b) Page Fault
c) Cache hit d) Cache Miss

40. If the required word is not found in the cache then it is termed as …………..
a) Page Hit b) Page Fault

115 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

c) Cache hit d) Cache Miss

41. Given a Computer System having a processor having clock cycle time 0.33ns with three
levels of Caches and Main Memory with the following parameters:
L1 Cache : Hit rate 0.94, Hit Time 2 clock cycles
L2 Cache : Hit rate 0.97, Hit Time 4 clock cycles
L3 Cache : Hit Rate 0.99, Hit Time 8 clock cycles
Main Memory : Miss Penalty 100 clock cycles
Compute the Average Time for accessing the Cache block
a) 0.15ns b) 0.085ns c) 0.095ns d) 0.075ns

42. ………………………..…………. occurs because the cache is initially empty.


a) TBL miss b) Capacity miss
c) Cold(Compulsory) miss d) Conflict miss

43. ………………………..…………. occurs when the cache is large enough, but multiple
data objects all map to the same block in the cache.
a) TBL miss b) Capacity miss
c) Cold(Compulsory) miss d) Conflict miss

44. ………………………..…………. Occurs when the set of active cache blocks is larger
than the cache(i.e., cache is full).
a) TBL miss b) Capacity miss
c) Cold(Compulsory) miss d) Conflict miss

45. In a program with good …………………., a memory location that is referenced once is
likely to be referenced again multiple times in the near future.
a) spatial locality b) temporal locality
c) functions d) datablocks

46. In a program with good …………………., if a memory location is referenced once,


then the program is likely to reference a nearby memory location close together
in time.
a) spatial locality b) temporal locality
c) functions d) datablocks

116 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[VIII] WRITE THE ANSWER IN THE BOX PROVIDED AGAINST EACH


OF THE MULTIPLE CHOICE QUESTIONS 50 POINTS
READ THE QUESTIONS CAREFULLY AND CORRECTLY.
FOR THIS QUESTION, ANSWER MUST BE WRIITEN, THAT IS, IN
THE BOX PROVIDED AGAINST EACH QUESTION IN THIS PART
ONLY

47. ………. Generates an exact copy of the current process that differs from the parent
process only in its PID.
a) exec b) fork c) init d) new

48. How many privilege levels are in Linux


a) 1 b) 2 c) 3 d) 4

49. To avoid the race condition, the number of processes that may be simultaneously inside
their critical section is
a) 1 b) 2 c) 3 d) 4

50. Which among the following interacts directly with system hardware?
a) Shell b) Commands c) Kernel d) Applications

51. Unix is which kind of Operating System?


a) Multi User b) Multi Processes c) Multi Tasking
d) All the above

52. Which of the following statement is FALSE ?


a) Unix supports multiple users
b) Linux is an open source operating system and the source code is shared
c) Shell takes care of inter process communication
d) Shell provides the feature of I/O Redirection

53. If an interrupt is generated from outside the CPU then it is an


a) asynchronous b) synchronous c) unhandleable d) handleable

54. If the interrupt is generated by the execution of an interrupt instruction then it


is
a) asynchronous b) synchronous c) unhandleable d) handleable

117 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

55. Example of an asynchronous interrupt is


a) divide by zero interrupt b) keyboard interrupt
c) overflow interrupt d) breakpoint interrupt

56. Example of a synchronous interrupt is


a) divide by zero interrupt b) keyboard interrupt
c) timer interrupt d) type2 interrupt

57. The interrupt for which the processor has highest priority among all the internal
interrupts is
a) keyboard interrupt b) TRAP c) NMI d) INT

58. Which command is used to find which process is taking how much CPU?
a) uptime b) top c) sed d) ps

59. Physical memory is broken into fixed-sized blocks called ______________.


a) page frames b) pages c) Segments d) Directories
60. The physical address of the Page Directory Table (Level 1 Page Table) is stored in
………… processor control register
a) cr0 b) cr1 c) cr2 d) cr3

61. Synchronous exception Traps are …………………………………………………………………


a) Intentional b) Intentional & Unrecoverable

c) Unintentional but possibly recoverable d) Unintentional & Unrecoverable

62. Synchronous exception Faults are …………………………………………………………………


a) Intentional b) Intentional & Unrecoverable

c) Unintentional but possibly recoverable d) Unintentional & Unrecoverable

63. Synchronous exception Aborts are …………………………………………………………………


a) Intentional b) Intentional & Unrecoverable

c) Unintentional but possibly recoverable d) Unintentional & Unrecoverable

64. An example of Synchronous exception Trap is ……………………………………………………


a) System Call b) Page fault
c) Floating point exception d) Illegal Instruction

65. An example of Synchronous exception fault is ……………………………………………………


a) System Call b) Page fault

118 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

c) Parity error d) Illegal Instruction

66. An example of Synchronous exception Abort is ……………………………………………………


a) System Call b) Page fault
c) Floating point exception d) Illegal Instruction

67. The ID number of x86-64 System call kill is ………


a) 57 b) 59 c) 60 d) 62

68. The ID number of x86-64 System call exit is ………


a) 57 b) 59 c) 60 d) 62

69. The ID number of x86-64 System call execve is ………


a) 57 b) 59 c) 60 d) 62

70. The ID number of x86-64 System call fork is ………


a) 57 b) 59 c) 60 d) 62

71. Control flow passes from one process to another process via …………………..
a) Jump instruction b) Call instruction
c) Return instruction d) Context switching

72. If a child process terminates before the parent process dies then the child process is
termed as …………………..
a) Bad process b) Orphan process
c) Dead process d) Zombie process

73. If a child process terminates after the parent process dies then the child process is
termed as …………………..
a) Bad process b) Orphan process
c) Dead process d) Zombie process

74. If any parent process terminates without reaping a child, then the orphaned child will
be reaped by …………….
a) swapper process b) process scheduler
c) init process d) concurrent process

75. A ………………is a small message that notifies a process that an event of some type
has occurred in the system
a) System Call b) Signal
c) Exception d) Interrupt

119 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

76. A ………………is an explicit request made to the kernel to get a particular operating
system service via interrupt
a) System Call b) Signal
c) Exception d) Interrupt

77. Each core can execute a separate process. Scheduling of processes onto cores is done
by ………………..
a) application b) kernel
c) I/O device d) Timer

78. Given the following timing diagram showing the execution flows for four different
processes A, B, C & D. Identify the processes which are running concurrently and the
processes running sequentially.

a) Concurrent A & B, Sequential B & C, C & D


b) Concurrent A & B, A & D, Sequential B & C, C & D
c) Concurrent A & B, A & C, A & D, Sequential B & C, C & D

d) Concurrent A & B, A & C, A & D, B & C, B & D, Sequential C & D

79. A fork system call returns ………… to the child process and …………………………….to the
parent process.
a) PID of parent, 1 b) PID of child, 0
c) 0, PID of child d) PID of parent, 0

80. The function to get the PID of a calling process is ……………………………………..


a) getpgrp b) getppgrp
c) getpid d) getppid

81. The function to get the PID of the parent process of a calling process is ……………….

120 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

a) getpgrp b) getppgrp
c) getpid d) getppid

82. …………………………………………………… function is used by the parent to reap a


child
a) wnohang b) waitpid
c) wuntraced d) wstopped

83. Function is ……………………….. if either reentrant (e.g., all variables stored on


stack frame,) or non-interruptible by signals.
a) sync-signal-unsafe b) async-signal-safe
c) async-signal-unsafe d) sync-signal-safe

84. If the calling process has no children, the waitpid returns ……… and set errno to……
a) -1, EINTR b) 0, EINTR
c) -1, ECHILD d) 0, ECHILD

85. If the waitpid function was interrupted by a signal, then returns ..…… and set
errno to …………..…..
a) -1, EINTR b) 0, EINTR
c) -1, ECHILD d) 0, ECHILD

86. setjmp function initially returns a value …………………. and after that it returns the value
provided by the function …………………………………………..
a) 1, fork b) 0, execve c) 0, longjmp d) 1, longjmp

87. Function execve is ………………………………….


a) called once, never returns b) called once, returns only once
c) called once, returns twice d) called once, returns one or more times

88. Function fork is ………………………………….


a) called once, never returns b) called once, returns only once
c) called once, returns twice d) called once, returns one or more times

89. Function exit is ………………………………….


a) called once, never returns b) called once, returns only once
c) called once, returns twice d) called once, returns one or more times

90. Function setjmp is ………………………………….


a) called once, never returns b) called once, returns only once
c) called once, returns twice d) called once, returns one or more times

91. Function longjmp is ………………………………….


a) called once, never returns b) called once, returns only once

121 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

c) called once, returns twice d) called once, returns one or more times

[IX] WRITE THE ANSWER IN THE BOX PROVIDED AGAINST EACH


OF THE MULTIPLE CHOICE QUESTIONS 50 POINTS
READ THE QUESTIONS CAREFULLY AND CORRECTLY.
FOR THIS QUESTION, ANSWER MUST BE WRIITEN, THAT IS,
TYPED IN THE BOX PROVIDED AGAINST EACH QUESTION IN
THIS PART ONLY

92. Given the following program and the corresponding process graph, Identify atleast
one infeasible output

void main()
{
printf("L0\n");
if (fork() != 0) {
printf("L1\n");
if (fork() != 0) {
printf("L2\
n");
}
}
printf("Bye\n");}

a) L0, L1, Bye, L2, Bye, Bye b) L0, Bye, L!, Bye, L2, Bye
c) L0, Bye, L1, Bye, Bye, L2 d) L0, L1, Bye, Bye, L2, Bye

93. Applications can explicitly block and unblock selected signals using the
…………………………function:
a) sigaddset b) sigfillset
c) sigdelset d) sigprocmask

94. Two signals which cannot be caught by a process are ………………………….


a) SIGQUIT & SIGINT b) SIGKILL & SIGCHLD
c) SIGSTOP & SIGQUIT d) SIGSTOP & SIGKILL

95. The default action taken by the kernel after a process receives the signal
SIGINT is………………..

122 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

a) Terminate b) Terminate with Dump


c) Ignore d) Suspend

96. The default action taken by the kernel after a process receives the signal
SIGKILL is………………..
a) Terminate b) Terminate with Dump
c) Ignore d) Suspend

97. The default action taken by the kernel after a process receives the signal
SIGSTOP is………………..
a) Terminate b) Terminate with Dump
c) Ignore d) Suspend

98. The default action taken by the kernel after a process receives the signal
SIGQUIT is………………..
a) Terminate b) Terminate with Dump
c) Ignore d) Suspend

99. The default action taken by the kernel after a process receives the signal
SIGCHLD is………………..
a) Terminate b) Terminate with Dump
c) Ignore d) Suspend

100. ……………… is considered mainly as a mechanism that the operating


system
kernel uses to run multiple application programs.
a) Exception b) Interrupt
c) Concurrency d) fork

101. Applications that use application-level concurrency are known as


……………
programs.
a) Sequential b) Concurrent
c) Modular d) Atomic

102. Since processes have separate virtual address spaces, flows that want to communicate
with each other must use some kind of explicit …………………………….mechanism.
a) Parameter Passing b) Function call & return
c) Modular Programming d) Inter-process communication (IPC)

123 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

103. ……………………… is a form of concurrent programming where applications


explicitly schedule their own logical flows in the context of a single process.
a) Process b) Thread
c) I/O Multiplexing d) Inter-process communication (IPC)

104. ……………………… are logical flows that run in the context of a single process and
are scheduled by the kernel.
a) Processes b) Threads
c) I/O Multiplexing d) Inter-process communication (IPC)

105. ……………………… is a condition where a set of processes are waiting because


each process is holding on to a resource and waiting for some other resource that is
being held by another process which is also waiting for the resource held by another
resource in a chain. Hence, no process can go forward as no process is going to
release the resource held by it.
a) Starvation b) Live lock
c) Deadlock d) Race condition

106. ……………………… occurs when greedy high priority processes make shared
resources unavailable for long periods. The low-priority processes requiring these
resources will have to wait indefinitely and sometimes never get a chance to be
serviced.
a) Starvation b) Live lock
c) Deadlock d) Race condition

107. ……………………… occurs when all the processes are allowed to access the shared
resource (critical section) at the same time thereby producing an incorrect result
a) Starvation b) Live lock
c) Deadlock d) Race condition

108. ……………………… occurs when two or more processes continually repeat the same
interaction in response to changes in the other processes without doing any useful
work. These processes are not in the waiting state, and they are running concurrently
without progressing forward.
a) Starvation b) Live lock
c) Deadlock d) Race condition

109. Every peer thread in a process contains ……………………………………………….


a) Data registers, code, data, stack
b) Data registers, code, data, heap, stack
c) Data registers, code, data, kernel context
d) Data registers, Condition Codes, SP, PC, stack

124 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

110. The POSIX library function to create a peer thread is ………………………

a) pthread_self b) pthread_join
c) pthread_detach d) pthread_create

111. The POSIX library function to reap a peer thread by a main thread or another peer
thread is …………………………………………….
a) pthread_self b) pthread_join
c) pthread_detach d) pthread_create

112. The POSIX library function to determine its own thread ID by a calling thread is
………………………
a) pthread_self b) pthread_join
c) pthread_detach d) pthread_create

113. The POSIX library function to terminate a thread is ………………………


a) pthread_cancel b) pthread_join
c) pthread_detach d) pthread_exit

114. The POSIX library function to terminate the current thread by a peer thread is
………………………
a) pthread_cancel b) pthread_join
c) pthread_detach d) pthread_exit

115. The POSIX library function to make a peer thread non-joinable is


………………………
a) pthread_cancel b) pthread_join
c) pthread_detach d) pthread_exit

116. A variable x is shared if and only if multiple threads reference some instance of
x.
a) static b) dynamic
c) shared d) local

117. A …………………………. models the execution of n concurrent threads as a


trajectory through an n-dimensional Cartesian space.
a) process graph b) progress graph
c) Bar graph d) Pie graph

118. A ………………….. is a sequence of legal state transitions that describes one


possible concurrent execution of the threads.
a) process graph b) progress graph
c) Bar graph d) trajectory

119. The POSIX library function to initialize a semaphore is ………………………

125 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

a) sem_post b) sem_wait
c) sem_init d) sem_assign

120. Given the following timing diagram showing the execution flows for four different
threads A, B, C & D. You are given two cores on the processor to execute these four
threads. Each core can execute only one thread at a time. Please provide clearly how
these threads will be executed on the two cores of the processor chip.

a) Core 0 : Thread A1, A2, A3, Thread B1, B2, B3


Core 1: Thread C1, C2 Thread D1, D2
b) Core 0 : Thread A1, A2, A3 Thread C1, C2
Core 1: Thread B1, B2, B3 Thread D1, D2
c) Core 0 : Thread A1, A3, Thread B2, Thread C1, Thread C2
Core 1: Thread B1, B3, Thread A2, Thread D1 Thread D2
d) Core 0 : Thread A1, A2, A3 Thread C1, Thread D2
Core 1: Thread B1, B2, B3 Thread D1 Thread C2

121. The POSIX library function to perform P operation on a semaphore is


………………………
a) sem_post b) sem_wait
c) sem_init d) sem_assign

122. The POSIX library function to perform V operation on a semaphore is


………………………
a) sem_post b) sem_wait
c) sem_init d) sem_assign

126 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

123. In which one of the Classical Inter-Process Communication(IPC) problems, three


important issues such as deadlock, saturation and low concurrency are to be tackled
………………………
a) Producer-Consumer Problem
b) Readers-Writers Problem
c) Dining Philosophers Problem
d) None of the above

124. ……………………………………uses main memory efficiently by treating it as a


cache for an address space stored on disk, keeping only the active areas in main
memory, and transferring data back and forth between disk and memory as needed.
a) Fully Associative Cache b) Direct Mapped Cache
c) Set Associative Cache d) Virtual Memory

125. Consider the following program where main thread creates 2 threads. Identify all the
shared variables in the following program.
char **ptr; /* global var */ void *thread(void *vargp)
int main() {
{ long myid = (long)vargp;
long i; static int cnt = 0;
pthread_t tid[2];
char *msgs[2] = { printf("[%ld]: %s (cnt=%d)\n",
"Hello from foo",
myid, ptr[myid], ++cnt);
"Hello from bar"
return NULL;
};
ptr = msgs; }
for (i = 0; i < 2; i++)
pthread_create(&tid[I], NULL, thread,
(void *)i);
pthread_exit(NULL);
}

a) i, tid, myid b) i, cnt, myid


c) ptr, cnt, msgs d) i, cnt, msgs

126. Dedicated hardware on the CPU chip called the ………………………… translates
virtual addresses on the fly, using a look-up table stored in main memory whose
contents are managed by the operating system
a) Split Cache L1 b) Unified Cache L2
c) memory management unit (MMU) d) Unified Cache L3

127 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

127. The Page table which is used by MMU to translate virtual address to physical
address is stored in ……………………………..
a) Split Cache L1 b) Unified Cache L2
c) memory management unit (MMU) d) Main Memory

128. If the required page is found in the main memory then it is termed as …………..
a) Cache hit b) Cache Miss
c) Page Hit d) Page Fault

129. If the required page is not found in the main memory then it is termed as …………..
a) Cache hit b) Cache Miss
c) Page Hit d) Page Fault

128 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

[X] WRITE THE ANSWER IN THE BOX PROVIDED AGAINST EACH OF


THE MULTIPLE CHOICE QUESTIONS 50 POINTS
READ THE QUESTIONS CAREFULLY AND CORRECTLY.
FOR THIS QUESTION, ANSWER MUST BE WRIITEN, THAT IS,
TYPED IN THE BOX PROVIDED AGAINST EACH QUESTION IN
THIS PART ONLY
130. The notion of mapping a set of contiguous virtual pages to an arbitrary location in an
arbitrary file is known as ……………………...
a) I/O Mapping b) File Mapping
c) Memory Mapping d) Cache Mapping

131. ……………………………………is a small set-associative hardware cache inside the


CPU which maps virtual page numbers to physical page numbers
a) MMU b) Cache L1
c) Cache L2 d) TLB

132. TLB stands for ……………………………………………………….


a) Translation Look-alike Buffer b) Transformation Look-aside Buffer
c) Translation Look-aside Buffer d) Transformation Look-alike Buffer

133. Given a Virtual Memory System having 48-bit virtual address, 4KB Page size and
using a single Page table with 8 byte PTE (Page table entry), determine the amount
of Main Memory required to store a single Page Table.

a) 64TB b) 128TB
c) 256TB d) 512TB

134. Given a Virtual Memory System having 32-bit virtual address, 4KB Page size and
using a single Page table with 4 byte PTE (Page table entry), determine the amount
of Main Memory required to store a single Page Table.

129 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

a) 2MB b) 4MB
c) 2GB d) 4GB

135. …………………. function is used by linux process to create new areas of virtual
memory and to map objects into these areas.
a) vmap b) pmap
c) mmap d) munmap

136. …………………. function is used by linux process to delete regions of virtual


memory
a) vmap b) pmap
c) mmap d) munmap

137. Programs allocate blocks from the heap by calling the ……………….. function.
a) valloc b) palloc
c) malloc d) free

138. Programs free allocated heap blocks by calling the ……………… function.
a) valloc b) palloc
c) malloc d) free

139. Dynamic memory allocators manage an area of process virtual memory known as
the …………….
a) code b) data
c) heap d) stack

140. For each process, the kernel maintains a variable ………………… that points to the
top of the heap.
a) sp b) pc
c) cs d) brk

141. ………………………………occurs when there is enough aggregate free memory to


satisfy an allocate request, but no single free block is large enough to handle the
request.
a) False fragmentation b) Internal Fragmentation
c) External Fragmentation d) Compaction

142. ……………………… placement policy instead of starting each search at the


beginning of the list for a free block that fits the block to be allocated, it starts each
search where the previous search left off.
a) Worst Fit b) Best Fit
c) First Fit d) Next Fit

130 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

143. ……………………… placement policy searches the free list from the beginning and
chooses the first free block that fits the block to be allocated
a) Worst Fit b) Best Fit
c) First Fit d) Next Fit
144. ……………………… placement policy examines every free block and chooses
the free block with the smallest size that fits the block to be allocated
a) Worst Fit b) Best Fit
c) First Fit d) Next Fit

145. When the allocator frees an allocated block, there might be other free blocks that are
adjacent to the newly freed block. Such adjacent free blocks can cause a
phenomenon known as …………………………………., where there is a lot of
available free memory chopped up into small, unusable free blocks.
a) False fragmentation b) Internal Fragmentation
c) External Fragmentation d) Compaction

146. To combat false fragmentation, any practical allocator must merge adjacent free
blocks in a process known as ……………………..
a) Allocation b) De-allocation
c) Coalescing d) Splitting

147. The technique adopted by Linux to solve the external fragmentation problem is
based on the well-known …………………………..approach
a) Segregated Fits b) Segregated storage
c) Buddy system d) Segregated Free lists

148. In some situations, read and write transfer fewer bytes than the application requests.
This problem is known as ……………………..
a) Buffer Underflow b) Buffer Overflow
c) Short Counts d) File Flush

149. End of line (EOL) indicator used in Linux regular file is ……………………..

a) Line Feed(LF) b) Line Feed followed by Carriage Return


c) Carriage Return(CR) d) Carriage Return followed by Line Feed

150. End of line (EOL) indicator used in Windows regular file is ……………………..

a) Line Feed(LF) b) Line Feed followed by Carriage Return


c) Carriage Return(CR) d) Carriage Return followed by Line Feed

131 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

151. ………………………….. function is used to move the file position indicator to the
end of the file.
a) lseek(fd, 0L, 0); b) lseek(fd, 0L, 1);
c) lseek(fd, 0L, 2); d) lseek(fd, 0L, -1);

152. An application can retrieve information about a file sometimes called the file’s
metadata by calling the ……… and …………… functions.
a) read, fread b) open, fopen
c) lseek, fseek d) stat, fstat

153. When to use standard I/O ………………………………………………………..


a) When working with disk or terminal files
b) Inside signal handlers and when absolute highest performance is needed
c) When reading and writing network sockets
d) None of the above

154. When to use raw Unix I/O ………………………………………………………..


a) When working with disk or terminal files
b) Inside signal handlers and when absolute highest performance is needed
c) When reading and writing network sockets
d) None of the above

132 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

PLAGIARISM STATEMENT
I certify that this assignment/report is my own work, based
on my personal study and/or research and that I have
acknowledged all material and sources used in its preparation,
whether they be books, articles, reports, lecture notes, and any
other kind of document, electronic or personal communication.
I also certify that this assignment/report has not previously been
submitted for assessment in any other unit, except where
specific permission has been granted from all unit coordinators
involved, or at any other time in this unit, and that I have not
copied in part or whole or otherwise plagiarized the work of
other students and/or persons.

STUDENT NAME :
STUDENT ID :
SECTION NO. :
CLASS : SOPHOMORE LEVEL

133 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

SIGNATURE : DATE:29-05-2025

(IT IS MANDATORY FOR EVERY STUDENT TO SIGN THIS


PLAGIARISM STATEMENT. WITHOUT THIS FINAL
ASSIGNMENT REPORT WILL NOT BE GRADED)

************************************
END OF PART B

************************************
YOU CAN PUT ALL THE C PROGRAMS
DEVELOPED FOR PROGRAMMING
QUESTIONS IN PART A AND PART B
IMMEDIATELY AFTER THIS PAGE

134 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

135 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

136 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

137 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

138 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

139 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

140 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

141 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025


STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:

142 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025

You might also like