More on UART Interrupts; System Calls Reference on Interrupt Identification Register(IIR) slide 17 of

Slides:



Advertisements
Similar presentations
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.
Advertisements

1 CS345 Operating Systems Φροντιστήριο Άσκησης 1.
Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
UNIX Process Control Bach 7 Operating Systems Course Hebrew University Spring 2007.
1 Introduction Chapter What is an operating system 1.2 History of operating systems 1.3 The operating system zoo 1.4 Computer hardware review 1.5.
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 Control in Unix Operating Systems Hebrew University Spring 2004.
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.
CSSE Operating Systems
1 Introduction Chapter What is an operating system 1.2 History of operating systems 1.3 The operating system zoo 1.4 Computer hardware review 1.5.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Fork and Exec Unix Model Tutorial 3. Process Management Model The Unix process management model is split into two distinct operations : 1. The creation.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Process. Process Concept Process – a program in execution Textbook uses the terms job and process almost interchangeably A process includes: – program.
BINA RAMAMURTHY UNIVERSITY AT BUFFALO System Structure and Process Model 5/30/2013 Amrita-UB-MSES
The Programming Interface. Main Points Creating and managing processes – fork, exec, wait Performing I/O – open, read, write, close Communicating between.
Lecture Topics: 11/3 Address spaces Memory protection Creating a process –NT style –Unix style.
System Calls 1.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Today’s Topics Introducing process: the basic mechanism for concurrent programming –Process management related system calls Process creation Process termination.
Exec Function calls Used to begin a processes execution. Accomplished by overwriting process imaged of caller with that of called. Several flavors, use.
Chapter 1 Introduction 1.1 What is an operating system
The Structure of Processes. What is a Process? an instance of running program Program vs process(task) Program : just a passive collection of instructions.
Operating Systems Chapter 2
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Creating and Executing Processes
1 CSE 451 Section 2: Interrupts, Syscalls, Virtual Machines, and Project 1.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
System calls for Process management
Scis.regis.edu ● CS 468: Advanced UNIX Class 5 Dr. Jesús Borrego Regis University 1.
Operating Systems Process Creation
CS4315A. Berrached:CMS:UHD1 Process Management Chapter 6.
What is a Process? u A process is an executable “cradle” in which a program may run u This “cradle” provides an environment in which the program can run,
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Unix System Calls and Posix Threads.
Tutorial 3. In this tutorial we’ll see Fork() and Exec() system calls.
System calls for Process management Process creation, termination, waiting.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
1 Unix system calls fork( ) wait( ) exit( ). 2 How To Create New Processes? n Underlying mechanism -A process runs fork to create a child process -Parent.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
Process Related System Calls By Neha Hulkoti & Kavya Bhat.
Transmitter Interrupts Review of Receiver Interrupts How to Handle Transmitter Interrupts? Critical Regions Text: Tanenbaum
A process is a program in execution A running system consists of multiple processes – OS processes Processes started by the OS to do “system things” –
Process Tables; Threads
Protection of System Resources
Unix Process Management
CS 3305 System Calls Lecture 7.
Processes in Unix, Linux, and Windows
UNIX PROCESSES.
System Structure and Process Model
System Structure and Process Model
Processes in Unix, Linux, and Windows
Lecture 5: Process Creation
More on UART Interrupts; System Calls
System Structure B. Ramamurthy.
OPERATING SYSTEMS DESIGN AND IMPLEMENTATION Third Edition ANDREW S
Processes in Unix, Linux, and Windows
System Structure and Process Model
Process Tables; Threads
Transmitter Interrupts
Process Programming Interface
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Lecture 6: Multiprogramming and Context Switching
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
Process Description and Control in Unix
Process Description and Control in Unix
Presentation transcript:

More on UART Interrupts; System Calls Reference on Interrupt Identification Register(IIR) slide 17 of Reference on System Calls –text: Tanenbaum ch.1.6

How to Distinguish the Interrupts? Method 1: –Check the UART LSR to see if Receiver Data Ready (DR) bit or the Transmit Holding Register (THRE) bit is set. Then execute the corresponding Tx or Rx function. Method 2: –Check the UART Interrupt Identification Register (IIR)’s bits 1 and bit 2 to see what interrupt is active bit 2bit 1 bit 0 Interrupt Rx Data Ready Tx Holding Reg Empty –Note: Reading of IIR resets only the Tx Interrupt

Example of Using IIR iir = inpt(baseport + UART_IIR); switch (iir&UART_IIR_ID) {/* mask the 2-bit ID field */ case UART_IIR_RDI:/* it's a receiver int */ …. /* do Rx function */ case UART_IIR_THRI: /* it is a transmitter int */ …. /* do Tx function */ /* no need to turn off Tx int */ default: …. /* do default function */ } bit-wise operator

Pointers in Writing ISR  Don’t forget to ack the device.  Don’t forget to ack the PIC (send EOI)  You’re running with IF=0, so no need for cli(). Just leave interrupts off (iret will restore IF=1)  Do as little as possible in the int handler—you’re running on borrowed time, at least in the OS case.  You do need to use global variables to communicate with the program-level code. Int handlers have no parameters.  The global data accessed both from int handlers and program-level code causes “critical sections” in the program-level code, needing mutex protection, i.e., turning IF=0 during the critical section.  If more than one device is on the same IRQ, check the status of each and service all that are “ready” in the same interrupt. (If you do only one, you might miss the other, because the IRQ signals overlapped and appeared as only one to the PIC.) This point is relevant to the transmitter and receiver of a UART.

System Calls Interface between the user program and the OS User program executes a trap or system call instruction to transfer control to the OS OS uses parameters passed to carry out the OS calls and return control to the user program at the instruction after the system call

Steps in Making a System Call count = read (fd, buffer, nbytes); Table of Pointers

Major POSIX System Calls

More POSIX System Calls

System Calls for Process Management fork() : create a new process in UNIX After fork(), the original(parent) process and the copy(child) process go separate ways. All variables have the same values at the time of fork(). Subsequent changes in one process do not affect the other. If fork() is not successful, it returns -1 and no child process is created. If fork() is successful, it returns 0 to the child process and the child’s pid (some +ve number) to the parent process. The process can get the parent’s pid using getppid() and its own pid using getpid().

fork() Code Examples You can find some good code examples in:

fork() Example 1: #include main() { int pid; printf("I'm the original process with PID %d and PPID %d.\n", getpid(),getppid()); pid=fork(); /* Duplicate. Child and parent continue from here.*/ if (pid!=0) /* pid is non-zero, so I must be the parent */ { printf("I'm the parent process with PID %d and PPID %d.\n", getpid(),getppid()); printf("My child's PID is %d.\n", pid); } else /* pid is zero, so I must be the child. */ { printf("I'm the child process with PID %d and PPID %d.\n", getpid(),getppid()); } printf("PID %d terminates.\n",pid); /* Both processes execute this */ } $fork.exe... run the program. I'm the original process with PID and PPID I'm the parent process with PID and PPID My child's PID is I'm the child process with PID and PPID PID terminates.... child terminates. PID terminates.... parent terminates.

fork() Example 2: int x_ext = 2;/* external var */ int main() { int x=6;/*local (automatic) variable */ if (fork()){ x++; x_ext++; printf(“hello from parent, x=%d, x_ext=%d\n”, x, x_ext); } else printf(“hello from child, x=%d, x_ext=%d\n”, x, x_ext); } hello from parent, x=7, x_ext=3 hello from child, x=6, x_ext=2

execve(name, argv,environp): replace the current process image with one constructed from the contents of an executable file –name: name of file to be exec. –argv: pointer to argument array –environp: pointer to environment array System Calls for Process Management (cont’d)

execve Example: A stripped down shell: while (TRUE) {/* repeat forever */ type_prompt( );/* display prompt */ read_command (command, parameters);/* input from terminal */ if (fork() != 0) {/* fork off child process */ /* Parent code */ waitpid( -1, &status, 0);/* wait for child to exit */ } else { /* Child code */ execve (command, parameters, 0);/* execute command */ }

Details of the execve Program For the command: cp file1 file2 The main program of cp has the declaration: main(argc, argv, envp) –argc: no. of arguments –argv: pointer to an array (argv[0] points to “cp”, argv[1] points to “file1” etc) –envp: pointer to an array of strings of environment values The child process executes the cp program and passes to it the arguments file1, file2 The parent process with waitpid(-1,…)waits for any child process to finish and return with status=child’s exit status

Win32 APIs Extremely large set, in thousands. Some invoke system calls (using traps to the kernel). Some invoke library calls in user space. Varies with OS versions. UNIX’s GUI (X windows and Motif) runs in user space. Many Win32 APIs dealing with GUI are system calls.

Comparisons of UNIX and Win32 API Calls