Past MCQ/Short Response Qs Flashcards

(11 cards)

1
Q

In the following code the address printed by printf belongs to which section?

int *p;
p = malloc(sizeof(int));
printf(“&p=%p\n”, &p);

A

Stack

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

Question on insertion to freelist based on malloc implementation.

A

Check gradescope to see Q.

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

Question on insertion to freelist based on malloc implementation.

A

Check gradescope to see Q.

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

Q4 review

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

Which assertions are true about the following code?

char * p = (int *) malloc(10);
strcpy(p, “123456789012345”);
free(p);

I. This is an example of memory smashing
II. This is a bug but the program will not crash.
III. This is an example of a wild free.
IV. The program may crash in line 3

A

I and IV.

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

What is the initial value of the reference count of an i-node of a directory and why?

A

It is 2, one for entry in the parent and one that refers to the current directory.

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

What will this do?

int fd = open(“outfile”, O_RDWR);
if (fork()) {
dup2(fd, 1);
}
else {
write(1, “hello\n”, 6);
}

A

It sometimes prints “hello\n” to the outfile and sometimes to the terminal

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

Can a free object be next to another free object in the heap?

A

No, they would have been coalesced.

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

Q9 review

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

What gbd command shows where a segv happened?

A

where

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