COP 4225 Advanced Unix Programming

2y ago
28 Views
2 Downloads
307.59 KB
41 Pages
Last View : 13d ago
Last Download : 3m ago
Upload by : Camden Erdman
Transcription

COP 4225 Advanced Unix ProgrammingOperating System ReviewChi Zhangczhang@cs.fiu.edu1

About the CoursezPrerequisite: COP 4610zConcepts and PrincipleszProgramming{System CallszAdvanced Topics{Internals, Structures, Details{Unix / Linux2

What is an Operating System?zA general purpose software that actsas an intermediary between users of acomputer and the computer hardware.{Encapsulates hardware details.{Controls and coordinates the use of thehardware among the various applicationprograms for the various users.zUse the computer hardware in anefficient manner.3

Abstract View of O.S.4

OS Features Needed forMultiprogrammingzCPU scheduling – the system mustchoose among several jobs readyto run.zMemory management – the systemmust allocate the memory toseveral jobs.zI/O routine supplied by the system.zAllocation of devices (e.g. Diskusage).5

Parallel SystemszMultiprocessor systems with more thanone CPU in close communication.zTightly coupled system – processors sharememory and a clock; communicationusually takes place through the sharedmemory.zAdvantages of parallel system:{Increased throughput{Economical{Increased reliability6

Parallel Systems (Cont.)z Symmetric multiprocessing (SMP){Each processor runs an identical copy of the operatingsystem.{Many processes can run at once without performancedeterioration.{Most modern operating systems support SMP7

Computer-System Architecture8

Computer-System Operationz I/O devices and the CPU can executeconcurrently, competing for memory accesses.{Memory controller synchronizes accesses.z Each device controller has a local buffer.z CPU moves data between main memory andlocal buffers of controllers.z I/O is from the device to local buffer of controller.{The buffer size variesz Device controller informs CPU that it hasfinished its operation by causing an interrupt.9

Common Functions of Interruptsz Interrupt transfers control to the interrupt serviceroutine generally, through the interrupt vector,which contains the addresses of all the serviceroutines.z The operating system preserves the state of theCPU before the interrupt by storing registers andthe program counter.z Incoming interrupts are disabled while anotherinterrupt is being processed to prevent a lostinterrupt.z A trap is a software-generated interrupt causedeither by an error or a user request.10

I/O Structurez Device-status table contains entry for each I/Odevice indicating its type, address, and state.z Operating system indexes into I/O device table todetermine device status and to modify table entry toinclude interrupt.z After I/O starts, control returns to user program onlyupon I/O completion (Synchronous I/O).{ System call – request to the operating system to allowuser to wait for I/O completion.{ Wait instruction idles the CPU (could be used by otherprocesses) until the next interrupt{ Wait loop (contention for memory access and CPU).z Poll the device status if it does not support interrupt{ At most one I/O request is outstanding at a time, nosimultaneous I/O processing.z After I/O starts, control returns to user program withoutwaiting for I/O completion (Asynchronous I/O).11

Device-Status Table12

Direct Memory Access StructurezUsed for high-speed I/O devices able totransmit information at close to memoryspeeds.zDevice controller transfers blocks of datafrom buffer storage directly to mainmemory without CPU intervention.{Direct I/O: Device CPU Register MemzOnly one interrupt is generated per block,rather than the one interrupt per byte.13

Storage Hierarchyz Storage systems organized in hierarchy.{Speed / Cost / Volatilityz Caching – copying information into fasterstorage system{Consistency and Coherency (Multiple CPUs):guaranteed by the hardware.{main memory can be viewed as a last cache forsecondary storage (e.g. Hard disk).14

Moving-Head Disk MechanismDisk surface is logically divided into tracks, which are subdividedinto sectors.The disk controller determines the logical interaction between thedevice and the computer.15

Storage Structurez Memory-mapped I/O{Physical memory is only part of the entire addressspace.{Each location on the screen is mapped to a memorylocation in the address space.z Electronic Disk (Non-Volatile Memory){DRAM array battery-backed magnetic hard disk(small){If external power is off, the data are copied from RAMto the disk{When the external power is restored, the data arecopied back to the RAM.z ROM16

Hardware ProtectionzSharing system resources requiresoperating system to ensure that anincorrect program cannot cause otherprograms to execute incorrectly.{Dual-Mode Operation{I/O Protection{Memory Protection{CPU Protection (Time-Sharing)17

Dual-Mode Operationz Provide hardware support for two modes ofoperations.1. User mode – execution done on behalf of a user.2. Monitor mode (also kernel mode or system mode) –execution done on behalf of operating system. Privileged instructions can be issued only in monitor mode.z Mode bit added to computer hardware toindicate the current mode: monitor (0) or user(1).{ associated with each memory segment18

Dual-Mode Operation (Cont.)zOS boots in monitor mode.zOS starts user processes in user mode.zWhen an interrupt or fault occurs hardwareswitches to monitor mode.{trap for system callsInterrupt/faultmonitoruserset user modePrivileged instructions can be issued only in monitor mode.19

I/O ProtectionzAll I/O instructions are privilegedinstructions.zMust ensure that a user program couldnever gain control of the computer inmonitor mode (loaded by OS).20

Memory ProtectionzIn order to have memory protection, addtwo registers that determine the range oflegal addresses a program may access:{Base register – holds the smallest legalphysical memory address.{Limit register – contains the size of the rangezIn user mode, memory outside the definedrange is protected.{Attempts trap to error21

Hardware ProtectionzWhen executing in monitor mode, theoperating system has unrestricted accessto both monitor and user’s memory.{The system call implementation can write backto buffers in user processes.zThe load instructions for the base and limitregisters are privileged instructions.22

CPU Protectionz Timer – interrupts computer after specifiedperiod to ensure operating system maintainscontrol.{Timer is decremented every clock tick.{When timer reaches the value 0, an interruptoccurs and control transfers to OSz OS performs various housekeeping tasks andswitch context if necessary.z Load-timer is a privileged instruction.23

Common System ComponentszProcess ManagementzMain Memory ManagementzFile ManagementzI/O System ManagementzSecondary ManagementzNetworkingzProtection SystemzCommand-Interpreter System24

Process Managementz A process is a program in execution. A processneeds certain resources, including CPU time,memory, files, and I/O devices, to accomplish itstask.{program counter: the next instruction to execute.z OS is responsible for the following activities inconnection with process management.{Process creation and deletion.{process suspension and resumption.25

Main-Memory Managementz Memory is shared by the CPU and I/O devices.z Main memory is a volatile storage device.z The operating system is responsible for thefollowing activities in connections with memorymanagement:{ Keep track of which parts of memory are currentlybeing used and by whom.{ Decide which processes to load when memory spacebecomes available.{ Allocate and deallocate memory space as needed.26

File ManagementzThe operating system is responsible forthe following activities in file management:{File creation and deletion.{Directory creation and deletion.{Mapping files onto nonvolatile storage.{File backup on stable (nonvolatile) storagemedia.27

Secondary-Storage ManagementzThe operating system is responsiblefor the following activities in diskmanagement:{Free space management{Storage allocation{Disk scheduling28

I/O System ManagementzThe I/O system consists of:{A buffer-caching system{A general device-driver interface{Drivers for specific hardware devices29

Command-Interpreter SystemzThe program that reads and interpretscontrol statements is called variously:{command-line interpreter{shell (in UNIX)zIts function is to get and execute the nextcommand statement.{process creation and management, I/Ohandling, secondary-storage management,main-memory management, file-system access,protection, networking30

Additional Operating System FunctionsAdditional functions exist for ensuringefficient system operations. Resource allocation – allocating resources to multiple users or multiple jobs running at thesame time.Accounting – keep track of and record whichusers use how much and what kinds ofcomputer resources for account billing or foraccumulating usage statistics.Protection – ensuring that all access to systemresources is controlled.31

System Callsz System calls provide the interface betweena running program and the operatingsystem.z Three general methods are used to passparameters between a running programand the operating system.{Pass parameters in registers.{Store the parameters in a table in memory, andthe table address is passed as a parameter in aregister (Linux).{Push (store) the parameters onto the stack bythe program, and pop off the stack by operatingsystem.32

Passing of Parameters As A Table33

UNIX Running Multiple Programs fork() exec() wait() / waitpid() Foreground or Backgroundexecution. When a process is running inbackground, it cannot receive inputdirectly from the keyboard.34

Communication ModelszCommunication may take placeusing either message passing (e.g.socket) or shared memory.Msg PassingShared Memory35

System Programsz System programs provide a convenientenvironment for program development andexecution. The can be divided into:{ File manipulation{ Status information{ File modification{ Programming language support{ Program loading and execution{ Communications{ Application programsz The view of O.S. seen by users is defined by thesystem programs, rather than by system calls.36

UNIX System StructurezThe original UNIX operating systemhad limited structuring. The UNIXOS consists of two separable parts.{Systems programs{The kernelzeverything below the system-call interfaceand above the physical hardwarezProvides the file system, CPU scheduling,memory management, and other operatingsystem functions37

UNIX System Structure38

Mechanisms and PolicieszMechanisms determine how to dosomething, policies decide what will bedone.zThe separation of policy from mechanismallows maximum flexibility if policydecisions are to be changed later.{Timer is a mechanism for CPU protection, butdeciding how long the timer is to be set for aparticular user is a policy decision.39

System ImplementationzTraditionally written in assembly language,operating systems can now be written inhigher-level languages.zCode written in a high-level language:{can be written faster.{is more compact.{is easier to understand and debug.{easier to port (move to some other hardware) ifit is written in a high-level language.40

System Generation (SYSGEN)z Operating systems are designed to run on any ofa class of machines; the system must beconfigured for each specific computer site.z SYSGEN program obtains informationconcerning the specific configuration of thehardware system.z Bootstrap program – code stored in ROM that isable to locate the kernel, load it into memory,and start its execution.41

COP 4225 Advanced Unix Programming Operating System Review Chi Zhang czhang@cs.fiu.edu. 2 About the Course zPrerequisite: COP 4610 zConcepts and Principles zProgramming {System Calls zAdvanced Topics {Internals, Structur

Related Documents:

Unix 101: Introduction to UNIX (i.e. Unix for Windows Users) Mark Kegel September 7, 2005 1 Introduction to UNIX (i.e. Unix for Windows Users) The cold hard truth · this course is NOT sponsored by the CS dept. · you will not receive any credit at all introduce ourselv

UNIX and POSIX APIs: The POSIX APIs, The UNIX and POSIX Development Environment, API Common Characteristics. UNIT – 2 6 Hours UNIX Files: File Types, The UNIX and POSIX File System, The UNIX and POSIX File Attributes, Inodes in UNIX

208/230 208/230 208/230 208/230 208/230 12ACB COMPRESSOR SPECIFICATIONS 208/230 142104 18.0 129 23.7 12ACB36 42 38 38 57 50 MAN/MODEL COP/ZR22K3 PFV COP/ZR28K3 PFV COP/ZR34K3 PFV COP/ZR40K3 PFV COP/ZR46K3 PFV COP/ZR57K3 PFV The scroll compressor is quieter than a reciprocating

208/230 208/230 208/230 208/230 208/230 12ACB COMPRESSOR SPECIFICATIONS 208/230 142104 18.0 129 23.7 12ACB36 42 38 38 57 50 MAN/MODEL COP/ZR22K3 PFV COP/ZR28K3 PFV COP/ZR34K3 PFV COP/ZR40K3 PFV COP/ZR46K3 PFV COP/ZR57K3 PFV The scroll compressor is quieter than a reciprocatin

Heat Pump Review Heat Pump COP COPdependsuponthe.25 to .6 units input COP depends upon the application Dedicated Cooling DedicatedHeatPump 1.25 to 1.6 Dedicated Heat Pump Combination Cooling and Heat Pump Notice the COP is much lower than 41 F 110 Fto Cooling COP 1.00 / 0.35 2.86 ASHRAE minimum (5.86 COP) F to 140 F COP Useful Work

PicoScope 4225 PicoScope 4425 For maximum performance the PicoScope 4225 and 4425 automotive oscilloscopes should be connected to a USB 3.0 port on your PC or laptop. If powering either of these oscilloscopes from a USB 2.0 port, you may need a TA146 double-headed USB 2.0 cable, available separately from Pico Technology.

The PicoScope 4225 and 4425 oscilloscopes contain our latest advances in design. These advances give the scopes floating inputs, ConnectDetect, and a maximum input range of 200 V (reducing the need for attenuators). Floating inputs Unlike previous PicoScopes, the inputs on the PicoScope 4225 and 4425 have their

researchers agree that something important is missing from modern AIs (e.g., Hofs-tadter 2006). While this subfield of Artificial Intelligence is only just coalescing, “Artificial Gen-eral Intelligence” (hereafter, AGI) is the emerging term of art used to denote “real” AI (see, e.g., the edited volume Goertzel and Pennachin [2007]). As .