Hard to Detect Programming errors Flashcards

1
Q

When do race conditions occur?

A

They occur when multiple threads share the same variable.

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

What is the solution for race conditions?

A

Form group of shared variables between threads, such that variables in different groups can be changed independently without affecting the correctness of the system.

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

What must critical regions for the same group of shared variables have to be?

A

Mutually exclusive

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

What is keyword synchronized for race conditions?

A

A keyword that ensure only one thread can execute a particular block of code or method at a time.

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

What is the critical region?

A

A segment of a program where shared resources are accessed or modified, where improper syntonisation can lead to race conditions and accidents.

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

Why are race conditions hard to detect?

A

They involve unpredictable interleaving of concurrent threads. It’s hard to replicate time specific scenarios.

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

When does aliasing occur?

A

Aliasing occurs when two or more variables in a program refer to the same memory location.

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

Give an example of an aliasing problem?

A

Trying to swap two variables around without an auxiliary variable e.g.
x = y
y = x
(This would not work)

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

What is an auxiliary variable?

A

A temporary variable.

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