CSE 466 – Fall Introduction - 1

Slides:



Advertisements
Similar presentations
User-Mode Linux Ken C.K. Lee
Advertisements

More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Computer Systems/Operating Systems - Class 8
ECE 526 – Network Processing Systems Design Software-based Protocol Processing Chapter 7: D. E. Comer.
04/14/2008CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Chapter 2: Processes Topics –Processes –Threads –Process Scheduling –Inter Process Communication (IPC) Reference: Operating Systems Design and Implementation.
Processes CSCI 444/544 Operating Systems Fall 2008.
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.
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
Inter Process Communication:  It is an essential aspect of process management. By allowing processes to communicate with each other: 1.We can synchronize.
04/16/2010CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying an earlier edition.
Concurrency: Mutual Exclusion, Synchronization, Deadlock, and Starvation in Representative Operating Systems.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Race Conditions CS550 Operating Systems. Review So far, we have discussed Processes and Threads and talked about multithreading and MPI processes by example.
© 2004, D. J. Foreman 2-1 Concurrency, Processes and Threads.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
CSE 466 – Fall Introduction - 1 Remainder of Syllabus  Lecture  RTOS  Maestro In Linux  Distributed Control Architecture – distributed state.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
I/O Systems I/O Hardware Application I/O Interface
1 Module 12: I/O Systems n I/O hardware n Application I/O Interface n Kernel I/O Subsystem n Transforming I/O Requests to Hardware Operations n Performance.
CSE 466 – Fall Introduction - 1 Reentrant Driver open() { if (count++) return(0); else return(grab_resources()); } release() { if (--count) return(0);
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
June 6, 2002Serguei A. Mokhov, 1 Salsa Theory Debrief 2 COMP346 - Operating Systems Tutorial 6 Edition 1.1, June 19, 2002.
CSE 466 – Fall Introduction - 1 User / Kernel Space Physical Memory mem mapped I/O kernel code user pages user code GPLR virtual kernel C
Chapter 7 - Interprocess Communication Patterns
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
Copyright © Curt Hill More on Operating Systems Continuation of Introduction.
WORKING OF SCHEDULER IN OS
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
Operating Systems Review ENCE 360.
Process Management Process Concept Why only the global variables?
The Mach System Sri Ramkrishna.
Topics Covered What is Real Time Operating System (RTOS)
Applied Operating System Concepts -
Cross-platform Libraries Technology Presentation
Protection of System Resources
Concurrency, Processes and Threads
Chapter 2 Processes and Threads Today 2.1 Processes 2.2 Threads
Operating Systems: A Modern Perspective, Chapter 6
Process Synchronization and Communication
CSCI 315 Operating Systems Design
I/O Systems I/O Hardware Application I/O Interface
Operating Systems Chapter 5: Input/Output Management
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Synchronization Issues
Mid Term review CSC345.
Lecture Topics: 11/1 General Operating System Concepts Processes
Lecture 4- Threads, SMP, and Microkernels
Threads Chapter 4.
Chapter 5: I/O Systems.
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Concurrency, Processes and Threads
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Concurrency, Processes and Threads
Chapter 13: I/O Systems.
Module 12: I/O Systems I/O hardwared Application I/O Interface
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

CSE 466 – Fall 2000 - Introduction - 1 Another Look at Sem2 P1 and P2 runnable P1 runs, calls wait(), and continues Task switch to P2 P2 runs, waits and blocks P1 continues, signals and term. P2 continues, signals and term. signal wait OS/other process 2 process 1 void os_wait(sem2 *s) { save_flags(); cli(); scount--; if (scount < 0) { interruptible_sleep_on(&Q); } restore_flags() void os_signal(sem2 *s) { save_flags(); cli(); scount++; if (scount <= 0) { wake_up_interruptible(&Q); restore_flags(); } cli() not strictly necessary but though some kernel functions can cause user space page fault, leading to unplanned context switch. Alternative: wait_event_interruptible(&Q, scount < 0); CSE 466 – Fall 2000 - Introduction - 1

Reentrant Sonar Driver (The Lab Requirements) INIT ECHO open read process 2 process 1 OS/other Kernel/driver ISR TOP open read Wake P1,P2 P1, P2 get Same reading P2 could get a Newer reading if P1 or some other Process starts and Completes a new Measurement before P2 gets to run again. No limit to number of processes that can open /dev/sonar at once Read() always returns a fresh measurement – starts a new one or returns the one in progress. All blocked processes return the current reading or later one. write() unsupported, return –1; Example Sequence of Events Each process calls open() then read() Process 1 call blocks in read() after initiating the Sonar measurement (sleeps on a wait queue) Process 2 blocks in read() for results on current measurement ISR wakes up all of the processes on the wait queue (top half?) Process 1 resumes in the driver and returns the reading Process 2 resumes in the driver and returns the reading CSE 466 – Fall 2000 - Introduction - 2

Linux Interrupt Structure (Sonar Example) Linux Nomenclature for Interrupt handling Top Half – the actual ISR. Bottom Half – runs each time OS gets control if queued up by top half user space kernel space Top Half: Signal Driver (wake_up) ECHO task queue User Process High Level non-time Critical Processing s =open(“/dev/sonar”,..) read(s,distance,n); Not used in this case Watch for shared data between isr and device driver read() sonar_read() Compute distance, Copy to user space INIT CSE 466 – Fall 2000 - Introduction - 3

Problem Decomposition – A Case Study Robot Collision Avoidance System Sensors Electronic Compass and Sonar Range Finder Low Priority Processing Knowing where it is and deciding how to get where its going Time Critical Processing (device time scales) us - ms Sonar Travel Time Motor pulse train, and speed measurement Time Critical on Human Time Scales ~100Hz Collision avoidance, traction control, motor ramp Partition into Linux user process, top half, bottom half, hardware User Process (Task switch) Mapping, Planning, Plan Execution (Control Algorithm) Bottom Half (OS tick) Collision Avoidance Motor Ramp Traction Assist Top Half (interrupt) Motor Pulse Train Motor Speed Measurement Sonar Time of Flight CSE 466 – Fall 2000 - Introduction - 4

CSE 466 – Fall 2000 - Introduction - 5 Motor Interface Open() get exclusive control Read() return current actual speed Write() set desired speed (return error?) Close() stop motor and release control Device Driver implement open,read,write,close implement ramping, traction control continuously Successful turns of the motor should generate interrupts so that the driver can know the speed User Program and/or bottom half determine desired speed handle discrepancy between desired and actual speed CSE 466 – Fall 2000 - Introduction - 5

Schedule of task queues…bottom halves in Linux blah() other app Interrupt (motor turn) TOP HALF Increment turn count Compute average speed since last execution of bottom half. Clear turn count. Put speed and time into queue. Let queue overwrite old data as necessary BOT. HALF blah() rti sys call or tick OS: Do Tick or System Call Device Driver arrows represent passage of control not data EXECUTE TASK QUEU myapp blah() read() Block if queue is empty, return all speed measurements in the queue CSE 466 – Fall 2000 - Introduction - 6

CSE 466 – Fall 2000 - Introduction - 7 As a Task Diagram unblocked Task Switch motor_read done BH run BH queued OS chance myapp blocked in driver two measurments in the queue ISR TOP ISR BOT BH run Motor driver OS/other myapp process 2 process 1 myapp done P2 read Blocks, Task Q runs Unblocks Tick Tick myapp: read() Bottom half queues: scheduler, timer, immediate CSE 466 – Fall 2000 - Introduction - 7

Linux Interprocess Communication Producer Consumer w/ Pipes and Fork() void main() { int pfds[2]; pipe(pfds); if (fork()) producer(); else consumer(); } void producer() { // serial? int q = pfds[0]; while (1) {generate_data(buf); write(q, buf, n);} void consumer() { int q = pfds[1]; while (1) {read(q, buf, n); process_data(buf);} Single Reader, Single Writer Kernel ensures mutual exclusion (Read/Write are system calls) CSE 466 – Fall 2000 - Introduction - 8

FIFO’s, which are named pipes Process 1 void main() { mknod(“/tmp/myfifo”, S_IFIFO, ); // create a FIFO file node f = open(“/tmp/myfifo”, O_WRONLY); while (1) {generate_data(buf); write(q, buf, n);} } Process 2 f = open(“/tmp/myfifo”, O_RDONLY); while (1) {read(q, buf, n); process_data(buf);} Works for “unrelated” processes Multiple writers, Multiple readers Kernel ensures mutual exclusion Kernel does not control interleaving of writers, readers CSE 466 – Fall 2000 - Introduction - 9

Impement a FIFO w/ a Device Driver CSE 466 – Fall 2000 - Introduction - 10

CSE 466 – Fall 2000 - Introduction - 11 Shared Memory Can we do this with a device driver? There are dedicated systems calls to support shared memory which are more efficient than device drivers CSE 466 – Fall 2000 - Introduction - 11

CSE 466 – Fall 2000 - Introduction - 12 Message Queues Like FIFO’s but for data structures rather than bytes (Structured I/O) System calls Create a message queue Put messages on the message queue(q, message_pointer, message_type) Get messages from the queue(q, message_pointer, message_type); It’s a really ugly in C The data structure is serialized, but you can’t tell what the type is. Sender and Receiver have to agree on integer designations for data types) Java (and maybe C++) is sooo much better at this kind of thing CSE 466 – Fall 2000 - Introduction - 12

Implement w/ Shared Memory FIFO Shared Memory CSE 466 – Fall 2000 - Introduction - 13

CSE 466 – Fall 2000 - Introduction - 14 Sockets -- Networking s = socket(int domain, int type, int protocol) -- protocol is usually associated with domain but not always domain: internet, UNIX, apple-talk…etc. How to interpret that address bind(int s, sockaddr *addr, n) s is the socket identifier sockaddr is the address (june.cs.washington.edu) n is the length of the address Now it is like a pipe, you can do read/write, send/recv, listen/accept. Several types stream datagram sequential raw The protocol stack mapping from application level abstractions (open, read, socket) to HW and back CSE 466 – Fall 2000 - Introduction - 14