mock test Flashcards

1
Q

What are the 2 main functions of the OS

A

Extended machine - an abstraction of heterogeneous underlying hardware
Resource manager - managing and sharing hardware such as I/O devices and memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the text segment of the process address space used for

A

It is used to store the instructions of the program that are executed by the CPU.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

int *my_function(void) {
static int len = 10;
int ai[len];
int *pai = (int *) calloc(len, sizeof(int));
// other code is omitted
return pai;
}
Where is the process address space in len located

A

data segment

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

int *my_function(void) {
static int len = 10;
int ai[len];
int *pai = (int *) calloc(len, sizeof(int));
// other code is omitted
return pai;
}
When will the memory used by len be available for reuse

A

process termination

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

int *my_function(void) {
static int len = 10;
int ai[len];
int *pai = (int *) calloc(len, sizeof(int));
// other code is omitted
return pai;
}
In which area of the process address space is ai allocated

A

stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

int *my_function(void) {
static int len = 10;
int ai[len];
int *pai = (int *) calloc(len, sizeof(int));
// other code is omitted
return pai;
}
When will the memory used by ai be available for reuse

A

function return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

int *my_function(void) {
static int len = 10;
int ai[len];
int *pai = (int *) calloc(len, sizeof(int));
// other code is omitted
return pai;
}
Where in the process address space is the memory pointed to by pai

A

heap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

int *my_function(void) {
static int len = 10;
int ai[len];
int *pai = (int *) calloc(len, sizeof(int));
// other code is omitted
return pai;
}
When will the memory pointed to by pai be available for reuse

A

program exit

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

include <stdio.h></stdio.h>

#include <string.h>
#include <stdlib.h>
#define MAXSTR 256
struct business {
char* name;
int reg;
int tel;
char type;
};
int main(void) {
struct business b;
b.name = (char*) malloc(strnlen("Newcastle Widgets", MAXSTR - 1) + 1);
snprintf(b.name, MAX_STR, "%s", "Newcastle Widgets");
b.reg = 1234;
b.tel = 1912089000;
b.type = 'x';
// other program code omitted for brevity</stdlib.h></string.h>

free(b.name);
return 0; } On a 32 bit machine with 32 bit ints, what is the sum in bytes of the sizes of the fields of the business struct?
A

On a 32-bit machine with 32-bit integers, the size of the char* field name in the business struct is 4 bytes, because a pointer to a char occupies 4 bytes on a 32-bit machine.

The size of the int field reg is 4 bytes, because an int is 4 bytes on a 32-bit machine.

The size of the int field tel is also 4 bytes, for the same reason.

The size of the char field type is 1 byte, because a char is 1 byte on a 32-bit machine.

The sum of the sizes of the fields of the business struct is therefore 4 + 4 + 4 + 1 = 13 bytes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Briefly explain why CSMA protocols provide a better utilisation than Aloha protocols?

A

CSMA (Carrier Sense Multiple Access) protocols provide better utilization than Aloha protocols because they allow a node to only transmit when the channel is idle, rather than transmitting regardless of the state of the channel. This reduces the likelihood of collisions, which in turn increases the overall efficiency of the network.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe the operation of the P-persistent CSMA protocol?

A

When a host becomes ready to send, it senses the channel. If it is idle, it transmits with a probability p

If that slot is also idle, it either transmits or defers again, with probabilities p and q respectively

If a slot is busy, it waits a random amount of time and starts again

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Flow control formula

A

Frame Transmission time (seconds) = Frame size (bits) / Transmission rate (bits/sec)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Selective repeat Protocol calc

A

Transmission rate * 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Go back N protocol calc

A

Transmission rate + 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

go back N protocol

A

-It allows for sending N frames before receiving the acknowledgement for the first frame
-The frames are sequentially numbered
-It uses the concept of sliding windows at the sender and the receiver.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Selective repeat protocol

A

This protocol also provides for sending N frames before receiving the acknowledgement
for the first frame
The frames are sequentially numbered
It uses the concept of sliding windows at the sender and the receiver, and so is also called
Selective Repeat sliding window protocol

17
Q

Describe three ways in which Go Back N protocol differs from Selective repeat protocol.

A

Acknowledgements: The receiver in the Go back N protocol sends a NAK to indicate that a packet was not received correctly and a range of packets are resent after one NAK. The receiver in selective repeat can individually acknowledge packets and then NAK packets are individually resent by sender
Implementation of Go back N is easier to implement as it takes up less memory than selective repeat
Retransmission: Go back N is less efficient as due to even one NAK it has to resend the range of packets, but with Selective repeat packets can be resent efficiently