Project #3, Threads and Synchronization CS-3013 A-term 20091 Project #3 Threads and Synchronization CS-3013, Operating Systems A-term 2009 Due Tuesday,

Slides:



Advertisements
Similar presentations
Operating Systems Semaphores II
Advertisements

Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
CSCC69: Operating Systems
Multi-threaded applications SE SE-2811 Dr. Mark L. Hornick 2 What SE1011 students are told… When the main() method is called, the instructions.
Strings and Dynamic Memory Allocation CS-2301, B-Term Programming Assignment #6 Strings and Dynamic Memory Allocation CS-2301, System Programming.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
CS470 Lab 4 TA Notes. Objective Simulate the activities of a producer and consumer – Page 326 Use thread synchronization to solve the producer-consumer.
5.6.2 Thread Synchronization with Semaphores Semaphores can be used to notify other threads that events have occurred –Producer-consumer relationship Producer.
Project 1CS-3013 A-term Programming Project #1 Forking Processes Due Tuesday, September 8, 11:59 PM.
Programming project #4 1 CS502 Spring 2006 Programming Project #4 Web Server CS-502 Operating Systems Spring 2006.
Monitors CSCI 444/544 Operating Systems Fall 2008.
CS-3103 & CS-502, Summer 2006 Programming Project #31 Programming Project #3 Web Server CS-3103 & CS-502 Operating Systems.
Fundamentals of Python: From First Programs Through Data Structures
Pthread (continue) General pthread program structure –Encapsulate parallel parts (can be almost the whole program) in functions. –Use function arguments.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
CS 149: Operating Systems February 17 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java.
Control Structures FOR Statement Looping.
Java Programming: Advanced Topics
Project 1, Command Shell CS-502 (EMC) Fall Programming Project #1 Command Shell CS-502, Operating Systems EMC, Fall 2009 (Slides include materials.
Threads in Java. History  Process is a program in execution  Has stack/heap memory  Has a program counter  Multiuser operating systems since the sixties.
Multi-Threaded Application CSNB534 Asma Shakil. Overview Software applications employ a strategy called multi- threaded programming to split tasks into.
ICS 145B -- L. Bic1 Project: Main Memory Management Textbook: pages ICS 145B L. Bic.
CS 152: Programming Language Paradigms May 7 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak
Use of Coverity & Valgrind in Geant4 Gabriele Cosmo.
1 Confidential Enterprise Solutions Group Process and Threads.
CS 346 – Chapter 4 Threads –How they differ from processes –Definition, purpose Threads of the same process share: code, data, open files –Types –Support.
CS345 Operating Systems Threads Assignment 3. Process vs. Thread process: an address space with 1 or more threads executing within that address space,
Programming with POSIX* Threads Intel Software College.
Nachos Project 4 Lecturer: Hao-Hua Chu TA: Chun-Po Wang (Artoo) Date: 2008/10/25.
Concurrent Programming and Threads Threads Blocking a User Interface.
System calls for Process management
Multithreading in Java Sameer Singh Chauhan Lecturer, I. T. Dept., SVIT, Vasad.
Concurrency in Java Brad Vander Zanden. Processes and Threads Process: A self-contained execution environment Thread: Exists within a process and shares.
Multithreading Chapter Introduction Consider ability of _____________ to multitask –Breathing, heartbeat, chew gum, walk … In many situations we.
Lab 2 Parallel processing using NIOS II processors
CS140 Project 1: Threads Slides by Kiyoshi Shikuma.
Operating Systems Process Creation
Fall 2002 CS 325 Class Notes Page 1 Lecture 25 Today –exec() in Unix –CreateProcess in Windows Announcements.
Department of Computer Science and Software Engineering
Multi-Threading in Java
Multithreading. Multithreaded Programming A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is.
Homework Assignment #1 J. H. Wang Oct. 11, 2013.
CS 241 Section (03/15/2012). MP6 This MP is simple: – Create a ‘make’ utility.
Project 3. “System Call and Synchronization” By Dongjin Kim
The Process CIS 370, Fall 2009 CIS UMassD. The notion of a process In UNIX a process is an instance of a program in execution A job or a task Each process.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
System calls for Process management Process creation, termination, waiting.
1 CSE 451 Section 2: Processes, the shell, and system calls.
4330/6310 THIRD ASSIGNMENT Spring The problem (I) A post office with a single queue and several nameless clerks: Clerk 0 Customers waiting Clerk.
Homework-6 Questions : 2,10,15,22.
PROCESS MANAGEMENT IN MACH
PARALLEL PROGRAM CHALLENGES
Project 3 Threads and Synchronization
Threads in C Caryl Rahn.
Chapter 4: Threads.
HW1 and Synchronization & Queuing
Chapter 5: CPU Scheduling
Recitation 14: Proxy Lab Part 2
Midterm review: closed book multiple choice chapters 1 to 9
Multithreaded Programming
CIS 720 Mutual Exclusion 2.
Threads and Concurrency
Project #3 Threads and Synchronization
Thread Synchronization including Mutual Exclusion
First slide Rest of project 2 due next Friday Today:
CSE 451 Section 1/27/2000.
CS-3013 Operating Systems Hugh C. Lauer
CS 144 Advanced C++ Programming May 7 Class Meeting
CIS 720 Mutual Exclusion 2.
Presentation transcript:

Project #3, Threads and Synchronization CS-3013 A-term Project #3 Threads and Synchronization CS-3013, Operating Systems A-term 2009 Due Tuesday, September 22, 2009, 11:59 PM

Project #3, Threads and Synchronization CS-3013 A-term Objective To learn to use threads and synchronization mechanisms in user space To implement a multi-threaded program that aggressively pounds on a shared resource

Project #3, Threads and Synchronization CS-3013 A-term The Problem Model a communal bathroom used by both sexes Possible states of the bathroom:– Vacant Occupied by women Occupied by men Rules:– Anyone may enter if vacant A user may enter if occupied by same sex A user must wait until vacant if occupied by opposite sex –Any number of users may by waiting at same time.

Project #3, Threads and Synchronization CS-3013 A-term Implementation Control module:– A.h file and a.c file Interface:– Enum gender = {male, female}; void Enter(gender g); void Leave(void); void Initialize(...); Must correctly maintain:– State # of users in bathroom Gender of users in bathroom Waits until vacant if occupied by opposite gender Sets state to vacant if this is the last user occupying Multiple threads trying to access or change at same time!

Project #3, Threads and Synchronization CS-3013 A-term Multi-threaded Test Program main() function is master thread –Interprets argc and argv –Spawns n user threads Randomly sets gender, loop count of each user thread Specifies arrival time and stay time –Mean and standard deviation –Waits for user threads to finish –Prints summary –Exits cleanly With no outstanding user threads!

Project #3, Threads and Synchronization CS-3013 A-term User Thread Loops loop count times For each iteration:– Generate random arrival and stay times Sleep arrival units of time Invoke Enter(gender) –May wait a long time if occupied by opposite gender Sleep stay units of time Invoke Leave() Collect statistics Print statistics (min, max, average wait time to enter) Exit cleanly So that master thread knows that user thread is done

Project #3, Threads and Synchronization CS-3013 A-term As Simple as That! With a few minor challenges!

Project #3, Threads and Synchronization CS-3013 A-term Synchronization Challenges Shared database representing state of bathroom, count, etc. Mutex for protecting shared access Semaphore or condition variable for waiting Clean exit from user thread pthread_join or barrier synchronization & detach Printing to stdout from multiple threads Without getting mixed up.

Project #3, Threads and Synchronization CS-3013 A-term Other Challenges Random number generation Around a mean; use “standard deviation” for width Optional (extra credit) Poisson distribution for arrivals Gaussian distribution for stay times Simulating units of time #include Suggest 10 or 100 milliseconds for one time unit.

Project #3, Threads and Synchronization CS-3013 A-term Write-up Explain invariant of shared data structure Show Enter() and Leave() preserve invariant Or show states & state transition diagram Explain master thread and user thread relationship Creation and termination

Project #3, Threads and Synchronization CS-3013 A-term Individual and Class Project Suggest you define Common command line format Common.h file for control module May discuss algorithms, strategies, etc. May help each other test programs Write individual code Own style, own words, own documentation, etc.

Project #3, Threads and Synchronization CS-3013 A-term Due Date Project due on Tuesday, September 22, at 11:59 PM Submit via web-based Turnin Project 3 Report to instructor or TAs any difficulties

Project #3, Threads and Synchronization CS-3013 A-term Questions?