Your Id Soc2040 Sp Final Assignment Spring 2025
Your Id Soc2040 Sp Final Assignment Spring 2025
FINAL ASSIGNMENT
Submitted by
STUDENT NAME :
STUDENT ID :
SECTION NO :
SEMESTER YEAR : SPRING 2025
LEVEL : SOPHOMORE
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:
PLEDGE
INSERT YOUR
PHOTO HERE
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.
[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.
[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
[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:
[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);
}
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.
[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:
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
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
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
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
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
28) The Intel Core i7 processor can have each core executing ....... threads
a)1 b)2 c)4 d)8
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
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
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
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
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
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
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
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
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
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 ...............
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 :
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
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
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
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)
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
2003 ab 2012 5e
2004 ad 2013 47
2005 fe 2014 83
2006 ed 2015 c8
2007 ca 2016 7e
2008 de 2017 5f
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
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
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
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
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
137) Write the function performed by the following assembly language program
segment:
Registers: n in %rdx, result in %rax
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
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
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
150) A text file consists of .................... codes representing corresponding text characters.
152) A hard disk drive consists of collection of …………............. which provide surfaces
that are used to record information.
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.
160) In multiprogramming environment, the OS decides which process gets the processor
when and for how much time. This function is called ………….………………….
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.
167) …..... cache is a Split-cache which has separate Instruction Cache (IC) and a
separate Data Cache(DC).
************************************
END OF PART A
GOTO NEXT PAGE FOR PART B QUESTIONS
************************************
PART – B
(TOTAL POINTS : 2200)
(QUESTIONS [I] TO [X] – TOTALLY 10 QUESTIONS ON TOPICS
TAUGHT BETWEEN WEEK9 TO WEEK 14)
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.
(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:
(i) First Compute VPN bits = ……….. bits & VPO bits = …………… bits
VA
Set Valid Tag PPN Valid Tag PPN Valid Tag PPN Valid Tag PPN
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
(iv) L1 D-Cache is four-way set associative with 32 blocks with each block of size 4
bytes.
PA = ……………bits
Compute :
PPN : 0x……….…
74 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:
PA = 0x………………….
PA
Compute :
VA = 0x…………………
VA
Compute :
PPN : 0x……….…
PA = 0x………………….
PA
Compute :
VA = 0x…………………
VA
Compute :
PPN : 0x……….…
PA = 0x………………….
PA
Compute :
VA = 0x…………………
VA
Compute :
PPN : 0x……….…
PA = 0x………………….
PA
Compute :
VA = 0x…………………
VA
Compute :
PPN : 0x……….…
PA = 0x………………….
PA
Compute :
VA = 0x…………………
VA
Compute :
PPN : 0x……….…
PA = 0x………………….
79 FINAL ASSIGNMENT SPRING 2025 THURSDAY MAY 29, 2025
STUDENT NAME : STUDENT ID: SECTION NO: SIGNATURE:
PA
Compute :
[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);
}
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:
[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.
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):
/* PROGRAM wrongcnt.c */
volatile long cnt = 0;
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);
}
return NULL;
}
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
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.
[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.
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
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
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
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 ………………..
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
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
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
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
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?
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?
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
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?
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
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
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
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
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
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
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
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
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.
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
81. The function to get the PID of the parent process of a calling process is ……………….
a) getpgrp b) getppgrp
c) getpid d) getppid
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
c) called once, returns twice d) called once, returns one or more times
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
95. The default action taken by the kernel after a process receives the signal
SIGINT is………………..
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
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)
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)
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
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
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
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
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.
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);
}
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. 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
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.
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
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
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 ……………………..
150. End of line (EOL) indicator used in Windows regular file is ……………………..
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
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
SIGNATURE : DATE:29-05-2025
************************************
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