Reminders Form groups of 3 by tomorrow Start project 2! Today:

Slides:



Advertisements
Similar presentations
Threads. Readings r Silberschatz et al : Chapter 4.
Advertisements

Day 10 Threads. Threads and Processes  Process is seen as two entities Unit of resource allocation (process or task) Unit of dispatch or scheduling (thread.
CSE 451: Operating Systems Section 6 Project 2b; Midterm Review.
CSE 451: Operating Systems
1 CSE451 Section 3. 2 Reminders Start project 2! It’s long Read the assignment carefully Read it again Project 2 will be done in groups of 3 Today: Form.
CSE451 Section 3: Winter 2k7 Welcome to the world of concurrency! Kurtis Aaron Kimball
1 Reminders Start project 2! It’s long Read the assignment carefully Read it again Project 2 will be done in groups of 3 groups to me Part 1 due.
1 Reminders Start project 2! It’s long Read the assignment carefully Read it again Make sure your groups are correct Today: Project 2 intro CVS.
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Ch 4: Threads Dr. Mohamed Hefeeda.
Low level CASE: Source Code Management. Source Code Management  Also known as Configuration Management  Source Code Managers are tools that: –Archive.
SubVersioN – the new Central Service at DESY by Marian Gawron.
Chapter 1 Process and Thread. 1.2 process The address space of a program – Text – Code – Stack – Heap A set of registers – PC – SP Other resources – Files.
An Intro to Concurrent Versions System (CVS) ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University.
CVS – concurrent versions system Network Management Workshop intERlab at AIT Thailand March 11-15, 2008.
CSE 219 Computer Science III CVS
CS333 Intro to Operating Systems Jonathan Walpole.
Week 3 January 22, 2004 Adrienne Noble. Today CVS – a great tool to use with your groups Threads – basic thread operations Intro to synchronization Hand.
12 CVS Mauro Jaskelioff (originally by Gail Hopkins)
CSE 451: Operating Systems Section 4 Scheduling, Project 2 Intro, Threads.
Introduction to Git Yonglei Tao GVSU. Version Control Systems  Also known as Source Code Management systems  Increase your productivity by allowing.
NachOS Threads System Road Map through the Code Lab 3.
CSE 451: Operating Systems Section 6 Project 2b. Midterm  Scores will be on Catalyst and midterms were handed back on Friday(?) in class  Talk to Ed,
CISC2200 Threads Fall 09. Process  We learn the concept of process  A program in execution  A process owns some resources  A process executes a program.
CSE 451: Operating Systems Section 4 Project 2 Intro; Threads.
Carnegie Mellon Recitation 11: ProxyLab Fall 2009 November 16, 2009 Including Material from Previous Semesters' Recitations.
7/9/ Realizing Concurrency using Posix Threads (pthreads) B. Ramamurthy.
CMSC 421 Spring 2004 Section 0202 Part II: Process Management Chapter 5 Threads.
Backing up a machine with git
M.Sc. Juan Carlos Olivares Rojas
Concurrent Versions System User guide for CS408
Process Tables; Threads
CVS – concurrent versions system
CReSIS Git Tutorial.
CVS – concurrent versions system
CSE 451 Section 4 Project 1 Notes Looking ahead: Project 2.
CS 6560: Operating Systems Design
CSE 120 Principles of Operating
Processes.
An Intro to Concurrent Versions System (CVS)
Scheduler activations
Threads in C Caryl Rahn.
CS399 New Beginnings Jonathan Walpole.
Threading and Project 2 (Some slides taken from Sec. 3 Winter 2006)
Development and Deployment
Lab 1 introduction, debrief
Threads & multithreading
Processes in Unix, Linux, and Windows
Operating Systems Lecture 13.
Process Tables; Threads
Assembly Language Programming II: C Compiler Calling Sequences
CS510 Operating System Foundations
CSE451 – Section 6.
CVS Concurrent Versioning System
Lecture Topics: 11/1 General Operating System Concepts Processes
Version control with Git Part II
Operating System Concepts
CSE 451 Autumn 2003 Section 3 October 16.
Threads Chapter 5 2/17/2019 B.Ramamurthy.
Programming with Shared Memory
Jonathan Walpole Computer Science Portland State University
Threads Chapter 5 2/23/2019 B.Ramamurthy.
Still Chapter 2 (Based on Silberchatz’s text and Nachos Roadmap.)
October 9, 2002 Gary Kimura Lecture #5 October 9, 2002
Programming with Shared Memory
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
CS703 – Advanced Operating Systems
Welcome to the world of concurrency!
Presentation transcript:

Reminders Form groups of 3 by tomorrow Start project 2! Today: Email group usernames to me Start project 2! Read the assignment carefully Read it again Today: Project 2 intro CVS

Project 2 You have to: Part a due: October 26 Part b due: November 4 Implement a user thread library Implement synchronization primitives Solve a synchronization problem Implement a multithreaded web server Analyze and experiment with your design Write a report Part a due: October 26 Part b due: November 4 Part a Part b Not in VMWare Any linux host

Simplethreads We give you: Skeleton functions for thread interface Machine-specific code Support for creating new stacks Support for saving regs/switching stacks A generic queue When do you need one? Very simple test programs You should write more Singlethreaded web server

Simplethreads Code Structure tests/*.c Web server (web/sioux.c) Other apps include/sthread.h You write this lib/sthread_user.c lib/sthread_user.h lib/sthread_queue.h lib/sthread_ctx.h lib/sthread_switch.S lib/sthread_queue.c lib/sthread_ctx.c sthread_switch_i386.h sthread_switch_powerpc.h

Thread Operations Which ones do we need?

Thread Operations void sthread_init() Initialize the whole system sthread_t sthread_create(func start_func, void *arg) Create a new thread and make it runnable void sthread_yield() Give up the CPU void sthread_exit(void *ret) Exit current thread What about the TCB? struct _thread { sthread_ctx_t *saved_ctx; ……… } Others?

Sample multithreaded program int main(int argc, char **argv) { int i; sthread_init(); for(i=0; i<3; i++) if (sthread_create(thread_start, (void*)i) == NULL) { printf("sthread_create failed\n"); exit(1); } sthread_yield(); printf("back in main\n"); return 0; void *thread_start(void *arg) { printf("In thread_start, arg = %d\n", (int)arg); Output?

Managing Contexts (given) sthread_new_ctx(func_to_run) gives a new thread context that can be switched to sthread_free_ctx(some_old_ctx) Deletes the supplied context sthread_switch(oldctx, newctx) Puts current context into oldctx Takes newctx and makes it current

How sthread_switch works Thread 1 TCB … SP Thread 2 TCB … SP Xsthread_switch: pusha movl %esp,(%eax) movl %edx,%esp popa ret Thread 2 registers CPU ESP Thread 1 running Thread 2 ready Want to switch to thread 2…

Push old context CPU Thread 1 TCB … SP Thread 2 TCB … SP Xsthread_switch: pusha movl %esp,(%eax) movl %edx,%esp popa ret Thread 1 registers Thread 2 registers CPU ESP Thread 1 running Thread 2 ready

Save old stack pointer CPU Thread 1 TCB … SP Thread 2 TCB … SP Xsthread_switch: pusha movl %esp,(%eax) movl %edx,%esp popa ret Thread 1 registers Thread 2 registers CPU ESP Thread 1 running Thread 2 ready

Change stack pointers CPU Thread 1 TCB … SP Thread 2 TCB … SP Xsthread_switch: pusha movl %esp,(%eax) movl %edx,%esp popa ret Thread 1 registers Thread 2 registers CPU ESP Thread 1 ready Thread 2 running

Pop off new context CPU Thread 1 TCB … SP Thread 2 TCB … SP Xsthread_switch: pusha movl %esp,(%eax) movl %edx,%esp popa ret Thread 1 registers CPU ESP Thread 1 ready Thread 2 running

Done; return What got switched? CPU SP PC (how?) Other registers Thread 1 TCB … SP Thread 2 TCB … SP Xsthread_switch: pusha movl %esp,(%eax) movl %edx,%esp popa ret Thread 1 registers What got switched? SP PC (how?) Other registers CPU ESP Thread 1 ready Thread 2 running

Adjusting the PC CPU ret pops off the new return address! Thread 1 TCB … SP Thread 2 TCB … SP ret pops off the new return address! Thread 1 registers ra=0x400 ra=0x800 CPU ESP Thread 1 (stopped): switch(t1,t2); 0x400: printf(“test 1”); Thread 2 running: switch(t2,...); 0x800: printf(“test 2”); PC

Things to think about Who will call sthread_switch? Where does sthread_switch return? How do we delete a thread? Can a thread free its stack itself? Starting up a thread sthread_new_ctx doesn’t pass parameters to the function it runs How do you pass parameters to a function with no arguments?

Things to remember Your thread library is non-preemptive You can compare your implementation against pthreads (which is preemptive). ./configure --with-pthreads

What is CVS Version control system for source files Multiple users can work on the same file simultaneously

Why use CVS The other way: The CVS way: Keep every version of code, all with different names: Project2good Project2_10_13_04 Project2working Project2_Feb_2_alex Project2_old Send emails back and forth with new changes Merge different versions by hand The CVS way: One version, saved in the CVS repository Multiple people can work on the same file concurrently CVS merges the edited versions automatically as you put them back in the repository

Setting up CVS Set up CVS root setenv CVSROOT /cse451/groupa/cvs (bash) export CVSROOT=/cse451/groupa/cvs Initialize a repository (only one person per group) cd /cse451/groupa mkdir cvs cvs init

Setting up CVS (2) Add the simplethreads distribution tar xvfz simplethreads-1.10.tar.gz cd simplethreads-1.10 cvs import –m “initial code” simplethreads SIMPLETHREADS SIMPLETHREADS_1_10 cd .. rm –fr simplethreads-1.10 Vendor release

CVS Commands Check out a project to your home directory: cd ~ cvs checkout simplethreads Merge in new changes from repository (update): cvs update [files…] Save your edited files into the repository: cvs commit –m “fixed annoying bugs” [files…]

CVS Commands 2 Add a new file to the repository Check status of a file cvs add [files…] Check status of a file cvs status file.c Check differences between your file and one in the repository: cvs diff file.c cvs diff –r 1.1 file.c (specifies version) View log of changes for a file cvs log file.c More info: http://www.cvshome.org cvs --help-commands

CVS Remote Access Access CVS from another machine: setenv CVSROOT coredump.cs.washington.edu:/cse451/cse451a/cvs setenv CVS_RSH ssh (for CVS to know how to access repository) (add to ~/.login (csh) or ~/.profile (bash))