2018 Flashcards
Describe the FSP view of an abstract process. 4 points
-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
What is the meaning of -> ?
-> 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
What is the meaning of l ?
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
What is the meaning of (i < N)?
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
What is the meaning of COUNT[i + 1]?
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
What does alphabet mean?
The alphabet of a process is the set of actions in which it can engage
What does transition mean?
Transition is when actions cause transitions from one state to another
How to ensure that the two processes have mutually exclusive access to the other process?
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.
Describe the TWO methods by which a programmer can create a thread in a java program. How would you decide which method to use?
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
What is the new state? (4)
-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
What is the runnable state?(5)
-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.
What is the blocked state?(2)
-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
What is the waiting state?(4)
-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
What is the timed-waiting state?(5)
-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
What is the terminated state?
A thread dies naturally when it runs() method exists normally