Lec4-1 - Concurrent processes Processes and Threads Abhik...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Processes and Threads Abhik Roychoudhury CS 3211 National University of Singapore Modified from Kramer and Magee’s lecture notes. Reading material: Chapter 2 of Textbook. 1 Concurrent processes We structure complex systems as sets of simpler activities, each represented as a sequential process . Processes can overlap or be concurrent, so as to reflect the concurrency inherent in the physical world, or to offload time- consuming tasks, or to manage communications or other devices. Model processes as finite Concept of a process as a sequence of actions. Designing concurrent software can be complex and error prone. A rigorous engineering approach is essential. Model processes as finite state machines. Program processes as threads in Java. 2 Processes and threads Concepts : processes - units of sequential execution. Models : finite state processes (FSP) to model processes as sequences of actions. labelled transition systems (LTS) to analyse, display and animate behavior. Practice : Java threads 3 Going back to Concurrency Sequential program (also use the term process ) Constructs: -> Prefixing of an action Concurrent program (Concurrent composition of processes) Parallel Composition Relabeling of action names 4 | Choice Iterative repetition [These are the ones used in a modeling language like Promela or programming language like Java] (while connecting processes, connect the disparate set of action names) Hiding of actions (internal to a process, not visible to the concurrent composition) Modelling Processes Models are described using state machines, known as Labelled Transition Systems LTS . These are described textually as finite state processes ( FSP ) and displayed and analysed by the LTSA analysis tool. LTS - graphical form (state machines) FSP – textual form close to state machines Promela – imperative form (closer to programming) Java - programming language 5 Modeling processes A process is the execution of a sequential program. It is modeled as a finite state machine which transits from state to state by executing a sequence of atomic actions. a light switch LTS on a light switch on Æ off Æ on Æ off Æ on Æ off Æ ………. a sequence of actions or trace off 0 1 6
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 FSP - action prefix If x is an action and P a process then (x-> P) describes a process that initially engages in the action x and then behaves exactly as described by P . ONESHOT = (once -> STOP). ONESHOT state machine (terminating process) Convention: actions begin with lowercase letters PROCESSES begin with uppercase letters once 0 1 7 FSP - action prefix & recursion SWITCH = OFF, OFF = (on -> ON), ON = (off-> OFF). Repetitive behaviour uses recursion: on 0 1 Substituting to get a more succinct definition: SWITCH = OFF, OFF = (on ->(off->OFF)). And again: SWITCH = (on->off->SWITCH). off 8 animation using LTSA Ticked actions are eligible for selection.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 8

Lec4-1 - Concurrent processes Processes and Threads Abhik...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online