Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

DEFINITION..

  • In computer science, a thread of execution is the smallest sequence of programmed instructions that can be managed independently by an operating system scheduler

THREAD PROCESS..

  • A SEQUENCE OF PROGRAMMED INSTRUCTIONS…

SCHEDULING....

  • Scheduling is the method by which threads, processes or data flows are given access to system resources (e.g. processor time, communications bandwidth)

How Threads Differ From Multitasking OS Processes...

PROCESS THREAD

  • They are independent.
  • They exist as subset of a process.
  • They have separate address spaces.
  • Thread share their address spaces.
  • Context switching is slower.
  • Context switching is faster.

Use Of Multithreading…

  • It builds the ability for an application to remain responsive to input. In a single-threaded program, if the main execution thread blocks on a long-running task, the entire application can appear to freeze. 

PROCESS..

  • A process is the "heaviest" unit of kernel scheduling. Processes own resources allocated by the operating system. Resources include memory, file handles, sockets, device handles, and windows.

KERNEL THREAD..

  • A kernel thread is the "lightest" unit of kernel scheduling. At least one kernel thread exists within each process. If multiple kernel threads can exist within a process, then they share the same memory and file resources.

USER THREADS…

  • Threads are sometimes implemented in userspace libraries, thus called user threads. The kernel is unaware of them, so they are managed and scheduled in userspace.

FIBRES….

  • Fibres are an even lighter unit of scheduling which are cooperatively scheduled: a running fiber must explicitly "yield" to allow another fiber to run, which makes their implementation much easier than kernel or user threads

THREAD PROCESS...

THREAD AND FIBRE ISSUES..

  • Threads in the same process share the same address space , which may change the data structure underfoot.
  • If a user thread or a fiber performs a system call that blocks, the other user threads and fibers in the process are unable to run until the system call returns

SOLUTION..

  • A common solution to this problem is providing an I/O API which uses non-blocking I/O internally, and schedules another user thread or fiber while the I/O operation is in progress. Similar solutions can be provided for other blocking system calls.

MODELS…

  • Kernel-level threading : Threads created by the user are in 1-1 correspondence with schedulable entities in the kernel. This is the simplest possible threading implementation.
  •  N:1(User-level threading): An N:1 model implies that all application-level threads map to a single kernel-level scheduled entity; the kernel has no knowledge of the application threads.

M:N (Hybrid threading): M:N maps some M number of application threads onto some N number of kernel entities, or "virtual processors." This is a compromise between kernel-level ("1:1") and user-level ("N:1") threading.

PROGRAMM LANGUAGE SUPPORT…

  • . Many implementations of C and C++ provide support for threading on their own.
  • A few interpreted programming languages such as Ruby and (the CPython implementation of) Python support threading, but have a limitation that is known as a Global Interpreter Lock (GIL).

Thank You.....

Learn more about creating dynamic, engaging presentations with Prezi