Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 31 Today’s class Review of more C Operating system overview.

Slides:



Advertisements
Similar presentations
Distributed System Services Prepared By:- Monika Patel.
Advertisements

Chapter 2 Operating System Overview Operating Systems: Internals and Design Principles, 6/E William Stallings.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Introduction to Computer Administration Introduction.
CS 345 Computer System Overview
Informationsteknologi Tuesday, September 18, 2007 Computer Systems/Operating Systems - Class 61 Today’s class Finish review of C Process description and.
Informationsteknologi Thursday, September 6, 2007Computer Systems/Operating Systems - Class 21 Today’s class Finish computer system overview Review of.
CMPT 300: Operating Systems I Dr. Mohamed Hefeeda
Informationsteknologi Friday, September 14, 2007Computer Systems/Operating Systems - Class 51 Today’s class Finish operating system overview Review of.
1 Day 03 Introduction to C. 2 Memory layout and addresses r s int x = 5, y = 10; float f = 12.5, g = 9.8; char c = ‘r’, d = ‘s’;
1 CSSE 332 Structures, Command Line Arguments. 2 Multi-dimensional arrays Multi-dimensional arrays int points[3][4]; points [1][3] = 12; /* NOT points[3,4]
CSSE 332 Functions, Pointers in C. 2 Functions - why and how ? If a problem is large If a problem is large Modularization – easier to: Modularization.
Lecture 1: History of Operating System
Operating System (O.S.) Objectives & Functions
1 School of Computing Science Simon Fraser University CMPT 300: Operating Systems I Dr. Mohamed Hefeeda.
Operating System Overview
CSSE221: Software Dev. Honors Day 27 Announcements Announcements Projects turned in? Projects turned in? The 2 required Angel surveys are due by 9 pm tonight.
Chapter 8 Operating System Support
Chapter 1 and 2 Computer System and Operating System Overview
15213 C Primer 17 September Outline Overview comparison of C and Java Good evening Preprocessor Command line arguments Arrays and structures Pointers.
By Mr. Abdalla A. Shaame.  An operating system is a software component that acts as the core of a computer system.  It performs various functions and.
Chapter 2 Operating System Overview Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
Chapter 2 Operating System Overview Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
Operating System Overview
Operating System A program that controls the execution of application programs An interface between applications and hardware 1.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures.
CHAPTER 2 OPERATING SYSTEM OVERVIEW 1. Operating System Operating System Definition A program that controls the execution of application programs and.
1 Operating System Overview Chapter 2 Advanced Operating System.
Chapter 2 Operating System Overview Operating Systems: Internals and Design Principles, 6/E William Stallings.
Introduction Operating Systems. No. 2 Contents Definition of an Operating System (OS) Role of an Operating System History of Operating Systems Classification.
Composition and Evolution of Operating Systems Introduction to Operating Systems: Module 2.
Chapter 5 Operating System Support. Outline Operating system - Objective and function - types of OS Scheduling - Long term scheduling - Medium term scheduling.
◦ What is an Operating System? What is an Operating System? ◦ Operating System Objectives Operating System Objectives ◦ Services Provided by the Operating.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
1 Operating System Overview Chapter 2. 2 Operating System A program that controls the execution of application programs An interface between applications.
Operating System Principles And Multitasking
1 File Handling. 2 Storage seen so far All variables stored in memory Problem: the contents of memory are wiped out when the computer is powered off Example:
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
Chapter 2 Operating System Overview Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
CSE 232: C++ memory management Overview of Arrays Arrays are the simplest kind of data structure –One item right after another in memory (“contiguous range”
1 Operating System Overview Chapter 2. 2 Operating System A program that controls the execution of application programs An interface between applications.
1 From: Operating Systems Internals and Design Principles by William Stallings Chapter 2 Operating System Overview.
What we will cover A crash course in the basics of C “Teach yourself C in 21 days”
1 Operating System Overview Chapter 2. 2 Operating System A program that controls the execution of application programs An interface between applications.
Connecting to Files In order to read or write to a file, we need to make a connection to it. There are several functions for doing this. fopen() – makes.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Copyright Prentice Hall, Inc. 1 Operating System Overview.
1.3 Operating system services An operating system provide services to programs and to the users of the program. It provides an environment for the execution.
Chapter 2 Operating System Overview Dave Bremer Otago Polytechnic, N.Z. ©2008, Prentice Hall Operating Systems: Internals and Design Principles, 6/E William.
1.1 Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 1: Introduction What Operating Systems Do √ Computer-System Organization.
Operating System Overview
Intro to Pointers in C CSSE 332 Operating Systems
Operating System Overview
C Primer.
Day 03 Introduction to C.
Operating System Interface between a user and the computer hardware
Protection of System Resources
Day 02 Introduction to C.
File I/O.
Introduction to Operating System (OS)
Day 03 Introduction to C.
Operating System Overview
OPERATING SYSTEM OVERVIEW
Programming in C Input / Output.
Operating System Overview
File Handling.
Chapter 2 Operating System Overview
Functions Reasons Concepts Passing arguments to a function
15213 C Primer 17 September 2002.
Presentation transcript:

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 31 Today’s class Review of more C Operating system overview

Review of more C

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 33 File handling Open a file using “fopen” Returns a file pointer which is used to access the file Modes  Read(r) – error if file does not already exist. File pointer at the beginning of file.  Write(w) – create a new file (overwrite old one). File pointer at the beginning of file.  Append(a) – create a new file if file does not exist. Preserve the contents if file does exist and pointer at the end of the file. fprintf, fscanf, fclose

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 34 Example 8 #include int main(int argc, char *argv[]) { FILE *inFile=NULL; /* Declare a file pointer */ inFile = fopen(“test.txt”, “w”); /* open file for writing*/ if(inFile == NULL){ /* need to do explicit ERROR CHECKING */ exit(1); } /* write some data into the file */ fprintf(inFile, “Hello there”); /* don’t forget to release file pointer */ fclose(inFile); return 0; }

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 35 Reading until end of file int feof(FILE *) – The function is defined in stdio.h  Returns a non-zero value if end of file has been reached, and zero otherwise. Sample code: fscanf(inFile, "%d", &int1); // Try to read while (feof(inFile) == 0 ){ //If there is data, enter loop printf("%d \n", int1); //Do something with the data fscanf(inFile, "%d", &int1); //Try reading again } //go back to while to test if data was read

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 36 Functions – why and how If a problem is large Modularization – easier to code debug Code reuse Passing arguments to functions  By value  By reference Returning values from functions  By value  By reference

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 37 Functions – basic example Example 9 #include int sum(int a, int b); /* function prototype at start of file */ int main(int argc, char *argv[]) { int total = sum(4,5); /* call to the function */ printf(“The sum of 4 and 5 is %d\n”, total); } int sum(int a, int b){ /* the function itself - arguments passed by value*/ return (a+b); /* return by value */ }

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 38 Memory layout and addresses int x = 5, y = 10; float f = 12.5, g = 9.8; char c = ‘r’, d = ‘s’; r s x y f g c d

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 39 Pointers made easy float *f_addr; // pointer variable – holds an address to // a float float f; // data variable - holds a float ? f 4300 ? f_addr 4304 NULL f_addr = &f; // & = address operator ? 4300 ff_addr

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 310 *f_addr = 3.2; // indirection operator or dereferencing ff_addr g 4308 float g=*f_addr; // indirection: g is now 3.2 f = 1.3; ff_addr

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 311 Pointer operations Creation  int *ptr; Pointer assignment/initialization  ptr = &i; (where i is an int and &i is the address of i)  ptr = iPtr; (where iPtr is a pointer to an int) Pointer indirection or dereferencing  i = *ptr; (i is an int and *ptr is the int value pointed to by ptr)

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 312 Example 10 #include int main(int argc, char *argv[]) { int j; int *ptr; ptr=&j; /* initialize ptr before using it */ /* *ptr=4 does NOT initialize ptr */ *ptr=4; /* j <- 4 */ j=*ptr+1; /* j <- ??? */ return 0; }

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 313 Pointers and arrays int p[10], *ptr; // Both p and ptr are pointers // i.e. can hold addresses. // i.e. can hold addresses. // p is already pointing to a // fixed location and cannot // p is already pointing to a // fixed location and cannot // be changed. ptr is still // to be initialized. // to be initialized. p[i] is an int value. p, &p[i] and (p+i) are addresses or pointers. *p is the same as p[0] (They are both int values) *(p+i) is the same as p[i] (They are both int values)

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 314 Pointer arithmetic ptr = p; // or ptr = &p[0] ptr +=2; // ptr = ptr + 2 * sizeof(int) = ptr+8 bytes // ptr = = 3008 => ptr = &(p[2]); ERROR: p = ptr; because “p” is a constant address, points to the beginning of a static array.

Operating system overview

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 316 Operating System A program that controls the execution of application programs An interface between applications and hardware

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 317 Operating System Objectives Convenience  Makes the computer more convenient to use Efficiency  Allows computer system resources to be used in an efficient manner Ability to evolve  Permit effective development, testing, and introduction of new system functions without interfering with service

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 318 Layers of Computer System

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 319 Services Provided by the Operating System Program development  Editors and debuggers Program execution Access to I/O devices Controlled access to files System access

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 320 Services Provided by the Operating System Error detection and response  Internal and external hardware errors  Memory error  Device failure  Software errors  Arithmetic overflow  Access forbidden memory locations  Operating system cannot grant request of application

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 321 Services Provided by the Operating System Accounting  Collect usage statistics  Monitor performance  Used to anticipate future enhancements  Used for billing purposes

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 322 Operating System Responsible for managing resources Functions same way as ordinary computer software  It is a program that is executed Operating system relinquishes control of the processor for other software to run and depends on the processor to allow it to regain control

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 323

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 324 Kernel Portion of operating system that is in main memory Contains most frequently used functions Also called the nucleus

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 325 Evolution of an Operating System Hardware upgrades plus new types of hardware New services Fixes

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 326 Memory Protection User program executes in user mode  Certain instructions may not be executed Monitor executes in system, or kernel, mode  Privileged instructions are executed  Protected areas of memory may be accessed

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 327 I/O Devices Slow

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 328 Multiprogramming When one job needs to wait for I/O, the processor can switch to the other job

Informationsteknologi Monday, September 10, 2007Computer Systems/Operating Systems - Class 329 Time Sharing Using multiprogramming to handle multiple interactive jobs Processor’s time is shared among multiple users Multiple users simultaneously access the system through terminals