1 / 21

Threading Models in Visual Basic Language

Threading Models in Visual Basic Language. Student Name: Danyu Xu Student ID:98044. Process Execution of an individual program 3 Components - An executable program - Associated data needed by the Program -Execution by the Program All information the O/S needs to manage the process.

ciro
Download Presentation

Threading Models in Visual Basic Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Threading Models in Visual Basic Language Student Name: Danyu Xu Student ID:98044

  2. Process Execution of an individual program 3 Components - An executable program - Associated data needed by the Program -Execution by the Program All information the O/S needs to manage the process Thread A dispatchable unit of work An execution state(running,ready,etc.) Some per-thread static storage for local variables Access to the memory and resources of its process Process/Thread

  3. Benefits of a Thread • Less time to create a new thread than a process • Less time to terminate than a process • Less time to switch between two threads within the same process • Since threads within the same process share same files and memory, they can communicate with each other without invoking the kernel

  4. COM(Component Object Model) in Visual Basic • a software architecture that allows applications to be built from binary software components. • the underlying architecture that forms the foundation for higher-level software services , eg. OLE, ActiveX.

  5. COM(Component Object Model) in Visual Basic (Continued) • A mechanism for keeping track of whether an object is in use and deleting it when no longer needed. • A standard error-reporting mechanism and set of error codes and values. • A mechanism for apps to exchange objects.

  6. In-Process Server Component in VB-DLL • In-Process are always DLL (dynamic link libraries) files. DLL-A library containing API functions or procedures accessible to and called from an application. -ideal for implementing standard objects to reuse or share among apps. -ideal for defining interfaces implemented by other objects. -preferred to create high-performance objects without a user interface.

  7. In-Process Server Component in VB-DLL (Continued) -Windows API(Application Programming Interface) has a collection of functions and procedures stored in Dynamic-Link Libraries.

  8. Out-of-Process Server Component • Out-of-Process are always EXE (executable) files. -objects can execute in their own thread. -objects can be created and used both by client applications and by running the server as a standalone app.

  9. Difference Between DLL and EXE • The way Windows interacts with them

  10. Memory Organization of 16-bit OS Code for DLL A Data for DLL A Code for EXE B Data for EXE B Code for EXE A Data for EXE B -windows 3.x -if a program accidentally modifies another program’s memory, can bring down the system. -Every application has one and only one thread.

  11. Memory Organization of 32-bit OS Code for EXE A Code for DLL A Data for EXE A Data for DLL A =============== Code for DLL A Data for DLL A Code for EXE A Data for EXE A --process space – the memory app runs in --walled off from other app --lower level physical memory is shared WinNT Each object could have its own thread, or the app ;might have a fixes number of threads and could manage its objects across the threads.

  12. Communications Between Apps Under 32-bit OS • Mechanism of Marshalling • Proxy object – fake object exposes same interface as the actual object. -created by OLE. • Types of Marshalling: --Between Apps --Between networks(DCOM,overhead of marshalling function calls is negligible compared to transfer of large amount of data)

  13. Features of In-Process and Out-of-Process server • EXE -It can run as a stand-alone application apart from the client -does not share same address space under the OS. • DLL -server component and client share some of the same memory. - share the same executable space.

  14. Features of In-Process and Out-of-Process Server (Continued) • Performance --In-Process server shares the same process space with its client at run time --server and client share some of the same memory. --Public Creatable classes can be instantiated only as MultiUse objects. • Flexibility Out-of-Process server provide classes either SingleUse or MultiUse

  15. Threading Models • Apartment Threading Model (single threaded apartments) • Free Threading Model (multi threaded apartments) • Thread Neutral Apartment Model

  16. Apartment Threading Model A “logical container” that -creates an association between objects and, in some cases, threads. -a set of rules programmers must obey to receive the concurrency behavior they expect from COM environment. -system-supplied code that helps programmers manage thread concurrency with respect to COM objects. -object in each thread is unaware of objects in other threads and has its own separate copy of global data.

  17. A SingleUse Class can only supply one instance of itself One Instance – one server component A MultiUse class can supply more than one instance of itself per copy of its component. One server component – many instance SingleUse/MultiUse

  18. SingleUse/MultiUse (Continued) • Cons:high overhead • Pros:avoid blocking Blocking - >1 user try to call the same code at the same time.

  19. Single-threaded apartment (STA) • a set of COM objects associated with a particular thread. • a place where an object or a proxy "lives."

  20. Multi-Threaded Apartment (MTA) • a set of COM objects associated with a set of threads in the process such that any thread can call any object implementation directly without the interposition of system code.

  21. Thread Neutral Apartment Model • MTS

More Related