Skip to main content

Application Of Threads

 

Application Of Threads

Application Of Threads

This section discuss various implementation of threads. Multithreading concepts are implemented by pthread (POSIX standard), solaris, linux, window 2000 and java.

1. POSIX THREAD(Pthreads)

·         Pthread refers to the POSIX standard(IEEE 1003.IC) that defines an API for thread creation and sychronisation.

·         Prior to the of POSIX THREADS, each hardware vendor implemented their own version of threads.

·         As each implemented from the other, writing portable multithreaded application was difficult. Thus POSIX standardize the API for thread management.

·         The current Pthread API is defined only for C programming language and it is implemented as function with a header file Pthread.h and thread library.

·         The naming convention for Pthreads is well defined and the prefix of all the object or function is PTHREAD.

      


        Solaries Threads

·         Solaries 2 is a version of UNIX, that implements Pthreads API in addition to supporting user-level threads with a library containing APIs for thread creation and management.

·         Solaries implement multilevel thread support designed to provide considerable flexibility. It make use of four separate thread related concepts:

1.       Process. This is normal UNIX process and includes the user’s address space, stack and PCB.

2.       User level thread. A user level thread is a user created unit of execution within a process.these are created by application programmer.

They provide support for parallel execution within a process.

3.       Lightweight processes. A LWP is a mapping between user level and kernel threads.

4.       Kernel threads. These threads are visible to OS. They are managed by OS


LINUX Threads

·         Threads in linux are handled in a different way as compared to other operating system due to the open source nature of linux.

·         An  important  difference between linux threads and other threads is that linux does not differentiate between a process and a thread . a task represents basics unit of work in linux.

·         To create a child process, linux provides two system calls : fork and clone.

·         Clone call creates a child process like the fork call, but main difference is that, fork creates a child process that has itys own process context similar to that parent process whereas the child process created by clone shares parts of it execution context with the calling process, such as memory space, the file descriptor table and the signal handler table

·         At user level, various libraries that implements Pthreads are available. For example, linuxthreads,NPTL(native POSIX thread library ).


       Windows 2000 threads

·       Window 2000 implements the win32 API.

·       A Window Application  runs as a separate process where each process contains one or more threads.

·       Every thread of a process has access to the virtual address space of a process

·       The various data structure used by threads are:

1.      ETHEREAD (executive thread block).it includes pointer to the process to which thread belongs and the address of the routine in which the thread starts control.

2.      KTHREAD (kernel threads block). It includes scheduling and synchronistion information for the threads. It also includes the kernel stack and a pointer to TEB.KTHREAD also lies in kernel space and only kernel has access to it.

3.      TEB (thread environment block). It is a user space data structure that is accessed when thread is running in user mode. TEB contains a user model stack and an array for thread specific data



Comments

Popular posts from this blog

Monolithic Architecture

  Monolithic Architecture Monolith means composed all in one piece. The  Monolithic  application describes a single-tiered  software  application in which different components combined into a single program from a single platform. Components can be: Authorization — responsible for authorizing a user Presentation — responsible for handling HTTP requests and responding with either HTML or JSON/XML (for web services APIs). Business logic — the application’s business logic. Database layer — data access objects responsible for accessing the database. Application integration — integration with other services (e.g. via messaging or REST API). Or integration with any other Data sources. Notification module — responsible for sending email notifications whenever needed. Example for Monolithic Approach Consider an example of Ecommerce application, that authorizes customer, takes an order, check products inventory, authorize payment and ships ordered products. This applicat...

Time Sharing System and its Requirements

  Time sharing  system ·           Time sharing refers to the allocation of computer resources in a time dependent fashion to several program simultaneously ·           A time sharing system has many user terminals that are connected to same computer simultaneously. Using these terminal, different users can work on a system at the same time ·           Thus, it uses multi programming with a special CPU scheduling among all the last one, and then again beginning from the first one ·           In time sharing system, the CPU time is divided among all the users on schedule basis. ·           It release the CPU under any of the following three conditions: 1.         When the allotted time slice expires. 2.    ...

Service provided By An Operating System.

  List of five service provided by an operating system. Explain how  each provides convenience to users?     The main purpose of operating system is to provide environment for the execution of programs. Thus an operating system provides certain services to program and the users of those programs. However , different operating system can provide different set of service. Some of the basis services provided by operating system are: 1.         Program execution ·          Operating system provides a convenient environment where users can run their programs ·          The operating system performs memory allocation to programs, load them into appropriate location so that they can execute. The users need not to worry about all these tasks.   2.         I/O Operation ·        ...

Thread

Thread What is Thread? A thread is a flow of execution through the process code, with its own program counter that keeps track of which instruction to execute next, system registers which hold its current working variables, and a stack which contains the execution history. A thread shares with its peer threads few information like code segment, data segment and open files. When one thread alters a code segment memory item, all other threads see that. A thread is also called a  lightweight process . Threads provide a way to improve application performance through parallelism. Threads represent a software approach to improving performance of operating system by reducing the overhead thread is equivalent to a classical process. Each thread belongs to exactly one process and no thread can exist outside a process. Each thread represents a separate flow of control. Threads have been successfully used in implementing network servers and web server. They also provide a suitable foundation ...

Process Scheduling and Process Scheduling Queues

 Process Scheduling Definition The process scheduling is the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process on the basis of a particular strategy. Process scheduling is an essential part of a Multi programming operating systems. Such operating systems allow more than one process to be loaded into the executable memory at a time and the loaded process shares the CPU using time multiplexing. Process scheduling contains the subsequent sub-functions: 1. Scheduling:   Chooses the process to be executed next on the CPU. The scheduling function uses information from the Process Control Block's and selects a process based upon the scheduling policy in force. 2. Dispatching:   Sets up execution of the chosen process on the CPU. Such function involves setting up the execution environment of the process that are selected, and loading information from the PSR and registers fields of the selected into t...