Threaded Applications Introducing additional threads in a Delphi application is easy.

Slides:



Advertisements
Similar presentations
1 Symbian Client Server Architecture. 2 Client, who (a software module) needs service from service provider (another software module) Server, who provide.
Advertisements

Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
How to Build Multi- threaded Applications in.NET Mazen S. Alzogbi Technology Specialist Microsoft Corporation.
Categories of I/O Devices
Threads, SMP, and Microkernels
Computer Systems/Operating Systems - Class 8
CS444/CS544 Operating Systems Synchronization 2/16/2006 Prof. Searleman
Chapter 5 Processes and Threads Copyright © 2008.
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
Concurrency in Ada What concurrency is all about Relation to operating systems Language facilities vs library packages POSIX threads Ada concurrency Real.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Concurrency CS 510: Programming Languages David Walker.
1 Chapter 4 Threads Threads: Resource ownership and execution.
The Structure of the “THE” -Multiprogramming System Edsger W. Dijkstra Jimmy Pierce.
A. Frank - P. Weisberg Operating Systems Introduction to Tasks/Threads.
1 I/O Management in Representative Operating Systems.
Using Two Queues. Using Multiple Queues Suspended Processes Processor is faster than I/O so all processes could be waiting for I/O Processor is faster.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
Fundamentals of Python: From First Programs Through Data Structures
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Module 8: Server Management. Overview Server-level and instance-level resources such as memory and processes Database-level resources such as logical.
Process Description and Control. Process concepts n Definitions – replaces task, job – program in execution – entity that can be assigned to and executed.
Programming Network Servers Topic 6, Chapters 21, 22 Network Programming Kansas State University at Salina.
1 Chapter Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Threads, Thread management & Resource Management.
12/1/98 COP 4020 Programming Languages Parallel Programming in Ada and Java Gregory A. Riccardi Department of Computer Science Florida State University.
Multi-Threaded Application CSNB534 Asma Shakil. Overview Software applications employ a strategy called multi- threaded programming to split tasks into.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Introduction to Concurrency.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
1 Concurrency Architecture Types Tasks Synchronization –Semaphores –Monitors –Message Passing Concurrency in Ada Java Threads.
Threads G.Anuradha (Reference : William Stallings)
Copyright ©: University of Illinois CS 241 Staff1 Threads Systems Concepts.
Concurrency: Mutual Exclusion and Synchronization Chapter 5.
Threaded Programming in Python Adapted from Fundamentals of Python: From First Programs Through Data Structures CPE 401 / 601 Computer Network Systems.
System Components ● There are three main protected modules of the System  The Hardware Abstraction Layer ● A virtual machine to configure all devices.
Department of Computer Science and Software Engineering
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
Thread basics. A computer process Every time a program is executed a process is created It is managed via a data structure that keeps all things memory.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Cs431-cotter1 Processes and Threads Tanenbaum 2.1, 2.2 Crowley Chapters 3, 5 Stallings Chapter 3, 4 Silberschaz & Galvin 3, 4.
3/12/2013Computer Engg, IIT(BHU)1 OpenMP-1. OpenMP is a portable, multiprocessing API for shared memory computers OpenMP is not a “language” Instead,
Assembly Language Co-Routines
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
1 Threads, SMP, and Microkernels Chapter 4. 2 Process Resource ownership - process includes a virtual address space to hold the process image Scheduling/execution-
Concurrency in Java MD. ANISUR RAHMAN. slide 2 Concurrency  Multiprogramming  Single processor runs several programs at the same time  Each program.
Concurrent Programming in Java Based on Notes by J. Johns (based on Java in a Nutshell, Learning Java) Also Java Tutorial, Concurrent Programming in Java.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Threaded Programming in Python
Processes and threads.
Chapter 3: Process Concept
PROCESS MANAGEMENT IN MACH
Advanced Topics in Concurrency and Reactive Programming: Asynchronous Programming Majeed Kassis.
Operating System (013022) Dr. H. Iwidat
Async or Parallel? No they aren’t the same thing!
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process Concept
Computer Engg, IIT(BHU)
Lecture 21 Concurrency Introduction
CSCI 511 Operating Systems Chapter 5 (Part C) Monitor
Threads and Data Sharing
Threads and Concurrency
Threads Chapter 4.
Threaded Programming in Python
Chapter 3: Processes.
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
CS510 Operating System Foundations
Threads and Multithreading
Threads CSE 2431: Introduction to Operating Systems
Presentation transcript:

Threaded Applications Introducing additional threads in a Delphi application is easy

Threaded Applications A Thread is? Why would you introduce additional threads? Basic Thread Code Variables and Thread Safe Code Some Thread Models - Communication

What is a Thread ? Simple Program – Sequential Steps –Waits to read data –Single “Thread” Windows OS runs programs “at the same time” –Time allocation, System Waits The OS also allows sections of a program to run independently in the same way. Each TThread Object introduces an additional independent set of processor steps (thread) within the application.

Why Introduce Multiple Threads? Users are no longer prepared to wait –If more than (?) then Thread More efficient –Actions happen in other Thread wait cycles Many things lend themselves to “Background” running –Large database reports –Internet access Can make things simpler –Less need for state engines

Basic Thread Code Inherit from TThread Object –Override the Execute Routine. –Handle exceptions within Execute –Keep Execute Thread safe Must free TThread Object or the Application will not close –Must allow Execute to terminate

Thread Safety Code is unsafe when a variable can be changed by separate threads in an uncontrolled manner and the change affects the program flow. Procedure Local Variables are safe Object Private and Protected variables and objects can be managed Thread Local >> threadvar X: Integer; –Global Variable Equivalent ???

Synchronization Objects Used to manage access to variables TCriticalSection –Protect blocks of code Acquire Release TSimpleEvent –One Thread initiates action then waits until other thread has set the event

Synchronize Routine Only works with VCL thread You get to pass a procedure of object without parameters The procedure needs to be able to establish its context to access variables The calling thread is suspended until the procedure returns

Thread Communication Models Separate (console) process Single Run –Recover Results in OnTerminate Server with Post Messages –Post results home Server with Synchronized callback –Call VCL Thread with results Multiplexed Server –Wait for thread to complete action

Threads to Multiplex Listen on Port IP Session Database Access Sql Query Sql Results Quey And Wait Spawn session Handle Queries In order

Slides and demonstration code –