Threads and Locks.

Slides:



Advertisements
Similar presentations
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Advertisements

1 CS318 Project #3 Preemptive Kernel. 2 Continuing from Project 2 Project 2 involved: Context Switch Stack Manipulation Saving State Moving between threads,
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
Process Management. External View of the OS Hardware fork() CreateProcess() CreateThread() close() CloseHandle() sleep() semctl() signal() SetWaitableTimer()
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Process Concept An operating system executes a variety of programs
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Chapter 8 Windows Outline Programming Windows 2000 System structure Processes and threads in Windows 2000 Memory management The Windows 2000 file.
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 11 Case Study 2: Windows Vista Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CE Operating Systems Lecture 11 Windows – Object manager and process management.
1 Confidential Enterprise Solutions Group Process and Threads.
The Linux Operating System C. Blane Adcock Bryan Knehr Kevin Estep Jason Niesz.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Source: Operating System Concepts by Silberschatz, Galvin and Gagne.
Operating System Concepts and Techniques Lecture 4 Thread M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First ed.,
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
What is an Operating System? Various systems and their pros and cons –E.g. multi-tasking vs. Batch OS definitions –Resource allocator –Control program.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Chapter 4 – Thread Concepts
Introduction to threads
Segments Introduction: slides 3–12 5 minutes—will skip some
Chapter 3: Windows7 Part 5.
REAL-TIME OPERATING SYSTEMS
Processes and threads.
Process concept.
Windows and C++11 Threads and Locks
Process Management Process Concept Why only the global variables?
CS 6560: Operating Systems Design
Lesson Objectives Aims Key Words
OPERATING SYSTEMS CS3502 Fall 2017
Chapter 4 – Thread Concepts
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 4 Threads.
Operating Systems: A Modern Perspective, Chapter 6
Processes in Unix, Linux, and Windows
Chapter 3: Windows7 Part 2.
Chapter 3: Windows7 Part 5.
Windows Internals Brown-Bag Seminar Chapter 1 – Concepts and Tools
System Structure B. Ramamurthy.
Processes in Unix, Linux, and Windows
Modified by H. Schulzrinne 02/15/10 Chapter 4: Threads.
System Structure and Process Model
Chapter 3: Windows7 Part 2.
Mid Term review CSC345.
Threads and Concurrency
Threads Chapter 4.
Threads Chapter 5 2/17/2019 B.Ramamurthy.
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
Threads Chapter 5 2/23/2019 B.Ramamurthy.
Still Chapter 2 (Based on Silberchatz’s text and Nachos Roadmap.)
CS149D Elements of Computer Science
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix and Windows
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Process Description and Control in Unix
Process Description and Control in Unix
Process and Thread State Diagrams
Michael Blinn Ben Hejl Jane McHugh Matthew VanMater
Process and Thread State Diagrams
Chapter 3: Process Management
Presentation transcript:

Threads and Locks

Windows API Create, style, and manage Windows Manage files and directories Create and manage processes, threads, and synchronizers Load and unload dynamic link libraries Create and manage timers Read and write to the registry

Windows Processes and Virtual Memory Windows Processes are containers for: Threads—one primary thread at process start File handles Other Windows objects Allocated memory Process Diagram Windows uses a paged virtual memory system Virtual Memory Diagram

Windows Objects Windows supports internal objects and provides an API to access and manage them through handles. Kernel Objects—named, secured, system-wide Devices, Files, Symbolic links, Registry keys, Threads and Processes, Events, Mutexes, Semiphores, Memory-mapped files, Callbacks, pipes User Objects—GUI objects Window, Menu, Icon, Hook, … GDI Objects—Drawing objects Brush, Pen, DeviceContext, Bitmap, Metafile, …

Windows Objects and Handles A Windows object is a data structure that represents a system resource; e.g., file, thread, bitmap. Windows objects are created and accessed using the Win32 API. They reside in Kernel32.dll, User32.dll, or GDI32.dll. An application accesses those resources through a handle, usually returned from a Create function. Each handle refers to an entry in an internal object table that contains the address of a resource and means to identify the resource type.

Object API The Windows API provides functions which: Create an object, returning a handle Get an object handle using other information Get and set information about an object Close the object handle, possibly destroying the internal object Objects are reference counted and will be destroyed when all referring handles have been closed Kernel objects have security functions that manage ACLs

Kernel Objects Kernel objects are operating system resources like processes, threads, events, mutexes, semaphores, shared memory, and files. Kernel objects have security attributes and signaled state. A kernel object is always either signaled or unsignaled. An object in the unsignaled state will cause any thread that waits on the object’s handle to block. An object in the signaled state will not block a thread that called wait on its handle.

Threads A thread is a path of execution through a program’s code, plus a set of resources (stack, register state, etc.) assigned by the operating system. A thread lives in one and only one process. A process may have one or more threads. Each thread in the process has its own call stack, but it shares process code and global data with other threads in the process. Thus, local data is unique to each thread. Pointers are process specific, so threads can share pointers.

Starting A Process Every time a process starts, Windows creates a primary thread. The thread begins execution with the application’s startup code that initializes libraries and enters main. The process continues until main exits and library code calls ExitProcess. You will find demo code for starting a Windows process here: http://www.ecs.syr.edu/faculty/fawcett/handouts/Coretechnologies/T hreadsAndSynchronization/code/ProcessDemoWin32/ Here is a demo for starting up a process using C#: http://www.ecs.syr.edu/faculty/fawcett/handouts/Coretechnologies/T hreadsAndSynchronization/code/ProcessDemoDotNet/

Scheduling Threads Windows is a preemptive multi-tasking system. Each task is scheduled to run for some brief time period before another task is given control of a CPU core. Unlike Unix and Linux, in Windows, threads are the basic unit of scheduling. A thread can be in one of three possible states: Running Blocked or suspended, using virtually no CPU cycles, but consuming about 1 MB of memory per thread Ready to run, using virtually no CPU cycles

Scheduling Activities A running task is stopped by the scheduler if: It is blocked waiting for some system event or resource Its time slice expires and is placed back on the queue of ready to run threads It is suspended by putting itself to sleep for some time; e.g., waiting on a timer It is suspended by some other thread It is suspended by Windows while the OS takes care of some critical activity Blocked threads become ready to run when an event or resource they wait on becomes available; e.g., its handle becomes signaled. Suspended threads become ready to run when their suspend count is zero.

Scheduling Threads

We next discuss some of the benefits and liabilities of using threads.