[SOLVED] CS Q1 File descriptors 1 Point

$25

File Name: CS_Q1_File_descriptors_1_Point.zip
File Size: 282.6 KB

5/5 - (1 vote)

Q1 File descriptors 1 Point
Imagine that foo.txt file contains hello.
What is printed out on your screen at the end of the program?
int main () {
int fd1, fd2;
char buf[1];
pid_t cpid;
fd1 = open(foo.txt, O_RDONLY, 0); read(fd1, buf, 1);
printf(%s, buf);
cpid=fork();
read(fd1, buf, 1);
printf(%s, buf);
if(cpid>0){
wait();
close(fd1); }
return 0; }
heh
hehe
hel
hee
What will be printed out is non-deterministic
Q2 Segmentation 1 Point
Which of the following content needs to be saved to Process Control Block during the context switch, assuming segmentation-based virtual memory

management? (check all that apply)
The content in the Stack Segment base register
The content of the current stack frame
The content in the Program Counter register
The content in the Stack Segment bound register
Q3 segment vs. BB 1 Point
Which of the following statement about segmentation is wrong?
Different segments can have different sizes
The size of a segment cannot be larger than the size of the whole virtual
memory
The size of a segment could grow at run time
The main advantage of segment over dynamic relocation is that address translation becomes faster under segmentation
Q4 Accessing memory 5 Points
Say we have a system that provides 8-bit virtual address and 2 segments. The segments are code and stack only. The most significant bit of each virtual address is used to identify a segment. The code segments number is 0 and the stack segments number is 1. Lets suppose a process P1 is running and the segmentation of P1 is as follows. (Dont worry about bounds in this question. R and W in the table indicate readable and writable setting of the corresponding segment.)

Answer the following questions for the following memory access: movb 0xE5, %rax
Q4.1
1 Point
What is the segment bit for this access?
0 1 2 3
Q4.2
1 Point
What are the offset bits (i.e., the offset of this address in its corresponding segment) for this access?
110 0101 100 1100 011 0111 101 0101
Q4.3
1 Point

What is the physical address of the memory location accessed by this instruction?
0x9B 0xA5 0xDF 0xF2
Q4.4
1 Point
Does this access succeed or result in an error?
The access succeeds
The access results in an error
Q4.5
1 Point
What is the maximum size of the code segment that is supported by this system?
512 Bytes 256 Bytes 128 Bytes 64 Bytes

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS Q1 File descriptors 1 Point
$25