2018 Flashcards

1
Q

Describe the FSP view of an abstract process. 4 points

A

-ignores the details of state representation and program/machine instructions

  • simply considers a process as having a state modified by indivisible or atomic actions

-each action causes a transition from the current state to the next state

  • in order in which the actions are allowed to occur is determined by a FSM/LTG that is an abstract representation of the program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the meaning of -> ?

A

-> is an action prefix
If x is an action and p is a process then the action prefix (x -> p) describes a process that initially engages in the action x and then behaves as p

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

What is the meaning of l ?

A

l is the choice operator
If x and y are actions, p and q are processes then (x -> p l y -> q) describes a process in which initially enges in either of the actions x or y. After the first action has occurred, the subsequent behaviour is described by p if the first action was x and q if the first action was y

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

What is the meaning of (i < N)?

A

The choice (when (B) x -> p l y -> q) means that when the boolean guard b is true then the actions x and y can both be eligible to be chosen, if it’s false then the action x cannot be chosen

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

What is the meaning of COUNT[i + 1]?

A

COUNT[i + 1] is an index process.
For example COUNT[i + 1] allows local processes to be indexed, and thus their behaviour to be dependant on the index value

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

What does alphabet mean?

A

The alphabet of a process is the set of actions in which it can engage

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

What does transition mean?

A

Transition is when actions cause transitions from one state to another

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

How to ensure that the two processes have mutually exclusive access to the other process?

A

Mutual exclusive access to the PRINTER is achieved by the three processes to “lock” it before they can use it, by performing an acquire action. And when they have finished they must “unlock” it by performing a release action.

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

Describe the TWO methods by which a programmer can create a thread in a java program. How would you decide which method to use?

A

the two methods are “sub-classing the thread class” or implementing “runnable interface”

  • create a thread using the runnable interface if your class needs to subclass some other class, otherwise use sub-classing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the new state? (4)

A

-a new thread is created but not started, thereby leaving it in this state by executing
- Thread myThread = new MyThreadClass();
-in this state a thread is an empty thread object, no system resources have been allocated for it yet
-in this state calling any other methods besides start() will cause an IllegalThreadStateException

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

What is the runnable state?(5)

A

-a thread is in this state after executing the start() method
-myThread.start();
-start() creates the system resources necessary to run the thread, schedules it to run and calls its run() method
-its called runnable rather than running because the thread may not be running when in this state since there may be only a single processor
-when thread is running its runnable and is the current thread and its run() method is executing sequentially.

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

What is the blocked state?(2)

A

-blocked state means that another thread currently has “acquired ” or “holds” the lock and therefore the thread can not proceed and is blocked
-a thread in the blocked state is waiting for a monitor lock so that it can enter a synchronised block/method or reenter a synchronised block/method after calling object.wait

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

What is the waiting state?(4)

A

-a thread in the waiting state is waitinf for another thread to perform a particular action
-a thread is in the waiting state due to calling some methods with no timeout parameter
-a thread called wait() on an object and is waiting for another thread to call notify() or notifyAll() on that object
- a thread called otherthread.join() and is waiting for the specified thread otherthreadto.terminate

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

What is the timed-waiting state?(5)

A

-is a thread state for a waiting thread with a specified waiting time
-a thread is in the timed waiting state due to some methods with a specified positive waiting time.
-a thread calls sleep(t) and is waiting for the timeout t.
-a thread calls wait(t) and is waiting for the timeout t or another thread to call notify or notifyAll() on that object
-a thread calls Thread.join(t) and is waiting for the timeout t or is waiting for a specified thread to terminate

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

What is the terminated state?

A

A thread dies naturally when it runs() method exists normally

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