Programmer System Interaction 1 - PowerPoint PPT Presentation

1 / 45
About This Presentation
Title:

Programmer System Interaction 1

Description:

Every Bootable Device ( usually hard disk partition C: ) must have a consistent ' ... The Bootable O.S. Selector Menu for WINDOWS environment. ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 46
Provided by: psd1
Category:

less

Transcript and Presenter's Notes

Title: Programmer System Interaction 1


1
Programmer System Interaction -1
  • Objective To develop test Application
    Programs written in some High Level Language.
  • Requirements A computer System with
  • a) Requisite Peripherals.
  • b) Operating System with Proper I/O device
    driver programs installed and resident on Disk.
  • c) The corresponding Translator Program as
    well as System Libraries available in Disk.

2
Programmer System Interaction- 2
  • Assumptions
  • a) The Programmer develops the Program
    without knowing anything about the Computer
    System where it is to be executed.
  • b) The Computer System in Question is already
    having an Operating System along with other
    relevant System Programs resident on Disk and Non
    Volatile Main memory BIOS ROM/EPROM

3
Summarized Steps from Program Development to
Execution
  • Develop the Program.
  • Search for an Installation having a Computer
    System with all desired , compatible System
    Softwares installed and available on disk.
  • Get a Log In there.
  • Key in the developed program using some Editor A
    System Program via keyboard to create a High
    Level Source Code With the Aid of the concerned
    O.S. through the relevant Device Driver(s) .
  • Translate that Source Code using the existing
    Translators Another System Programs and then
    Link up the used Libraries to create an
    Executable Module.
  • Run execute it by the help of the O.S.

4
Steps involved in Program Development - 1
  • Identify Input Output Specifications i.e. what
    are given and what is to be produced.
  • Develop an algorithm.
  • Design/Specify a Data Structure (if needed) i.e.
    specify an Abstract Data Type (ADT).
  • Select a High level programming language (HLL).

5
Steps involved in Program Development - 2
  •    A) Implement the specified algorithm by a
    program (Source Code) using the selected HLL.
  • B) Design and implement the ADT using the
    Data type(s) of the selected HLL.

6
Program Development Steps Example - 1
  • Ex. Given two integers A B , Compute the
    quotient Q A/B and remainder R A modulo B .
  • Check for non zero B to ensure feasibility of
    division

7
Program Development Steps Example - 2
  • Algorithm (in English like Steps)
  • 1. Input value of A
  • 2. Input value of B
  • 3. If (B is Equal to 0) then
  • Print B is invalid Input Again go to step 2.
  • 4. (Here B is Non Zero) proceed with Division
  • Q A/B
  • 5. R A mod B
  • 6. Output (Print A,B,Q,R)
  • 7. Stop

8
The Implementing HLL (C ) Program - 1
  • include ltstdio.hgt / C Library Linkage
    Directive/
  • main ( ) / Start/
  • / begin main/
  • int I_A, I_B, I_Q, I_R / Variable
    declaration and
    storage reservation Directives . Non
    Executable Data Segment . /
  • / Code Segment Starts Here . Reserve Variable
    Spaces on STACK/
  • scanf ("d", I_A) / Input A , a System
    Call, Data Movement Activity /
  • scanf ("d", I_B) / Input B , another
    System Call/
  • while (I_B 0) / if B 0 , Control Flow/
  • /begin while/
  • printf ("B is invalid Input Again
    \n") / System Call/
  • scanf ("d", I_B) / Again input
    B (System Call)/
  • //end while

9
The implementing HLL (C) Program - 2
  • / Here B is non Zero/
  • I_Q I_A / I_B / Data Processing
    Activity/
  • I_R I_A I_B / Data Processing
    Activity/
  • printf ("A d \f Bd\f Qd\f Rd\n",
    I_A, I_B, I_Q, I_R) / System Call/
  • / end main /

10
The Actual Boot Process of a Typical Computer
System
  • In computing, booting is a bootstrapping process
    that starts the O.S. when the user powers on any
    computer system.
  • A boot sequence is the set of operations the
    computer performs when it is switched on to load
    an operating system and subsequently hand over
    control to it.
  • Booting , in a way, readies a Computer System
    for use.

11
Towards Program Execution on a PC ( The BOOT UP
Sequence - 1)
  • Assumed that the High Level Source Code has
    already been developed Off Line.
  • The System is Powered on.
  • The internal power supply of the System
    subsequently turns on and initializes. Before it
    stabilizes , the chipset will generate a reset
    signal to the processor until it receives the
    Power Good signal from the power supply.
  • Receipt of Power Good Signal , signifies that the
    processor is ready to execute program stored in
    Memory provided it knows where to start.

12
From Power on to Boot up on a PC - 2
  • 5. In order to achieve uniformity , the processor
    always look at the same place in the system non
    volatile Memory CMOS Flash / BIOS ROM for the
    very first machine Instruction to execute.
    This is normally location FFFFFFF0h, right at the
    end of the system memory.
  • This location is chosen because since there
    are only 16 bytes left from there to the end of
    conventional memory (FFFFFFFF H) , this location
    just contains a JUMP lt Start Addressgt "
    instruction telling the processor where to go to
    find the real START Up program.
  • This way enables one to keep the Flexibility
    so that the size of the Starting Program can be
    changed without creating compatibility problems.

13
From Power on to Boot up on a PC - 3
  • 3. This start up program next performs the
    power-on self test (POST). The POST is a built-in
    diagnostic program that checks the system
    hardware to ensure that everything is present and
    functioning properly, so that the BOOT process
    can proceed smoothly later.
  • This involves testing the following Devices in
    turn
  • a) The Video Card.
  • b) The Keyboard Mouse.
  • c) The Main Memory.
  • d) The BOOT Devices namely the CD/DVD Drives ,
    FLASH Drives (if connected) followed by the
    internal Hard Disk Drives.
  • If there are any fatal errors during this
    testing phase , the boot process stops with a
    beep. Because of absence of O.S. it is difficult
    to isolate the problem area in case of any error.

14
From Power on to Boot up on a PC - 8
  • 9. If the BIOS supports the Plug and Play
    standard, it will detect and configure Plug and
    Play devices at this time and display a message
    on the screen for each one it finds.
  • 10. The BIOS will display a summary screen
    about the system's configuration like Processor ,
    Memory, CACHE, Disk interfaces etc.

15
From Power on to Boot up on a PC - 9
  • 11. The BIOS begins the search for the Initial
    Program Loading Location (IPL) / drive to boot
    from based on an User alterable boot sequence
    BIOS setting

16
IPL Device Options in PCs
  • In a modern BIOS, the user can select one of
    several interfaces from which to boot. These
    include hard disk, floppy, SCSI, CDROM, Zip,
    LS-120, a network interface card using PXE, or
    USB (USB-FDD, USB-ZIP, USB-CDROM, USB-HDD).
  • For example, one can install Microsoft Windows on
    the first hard disk and Linux on the second. By
    changing the BIOS boot device, the user can
    select the operating system to load.

17
The Computer Start Up Problem- 1
  • Most computer systems can only execute code
    found in the memory (ROM or RAM/ RWM).
  • Modern operating systems are mostly stored on
    hard disks (occasionally on CDs/DVDs, USB flash
    drives, and the like).
  • Just after a computer has been turned on, it
    doesn't have an operating system in memory.

18
The Computer Start Up Problem - 2
  • 4. The computer's Start up Program is ill
    equipped to be able to perform complicated
    actions of the operating system, such as loading
    a program from disk.
  • 5. A seemingly irresolvable paradox is created
    to load the operating system into memory, one
    appears to need to have an operating system
    already installed in the Memory.
  • 6. Any Operating System, normally, is too big a
    program to be fitted into the Non Volatile
    portion of the main memory.

19
The BOOTSTRAP Loader
  • The solution to the paradox involves using a
    special small program, called a bootstrap loader
    or boot loader.
  • This program doesn't have the full functionality
    of an operating system, but is tailor-made to
    load enough other software for the operating
    system to start.
  • Often, multiple-stage boot loaders are used, in
    which several small programs summon each other,
    until the last of them loads the operating system
    from the Bootable Device / Initial Program
    Location (IPL).
  • The name bootstrap loader comes from the image of
    one pulling oneself up by one's bootstraps
    (bootstrapping).

20
From Power on to Boot up on a PC - 10
  • 12. Having identified its target boot drive, the
    BIOS looks for this BOOT STRAP Loader . If it is
    searching a hard disk, it looks for the master
    boot record at cylinder 0, head 0, sector 1 (the
    first sector on the disk) if it is searching
    some other Media like a Floppy/ CD/DVD , it looks
    at the same address on the disk for a volume
    boot sector.

21
The Master Boot Record (MBR)
  • Every Bootable Device ( usually hard disk
    partition C ) must have a consistent "starting
    point" where key information is stored about the
    disk, such as how many partitions it has, what
    sort of partitions they are, etc. There also
    needs to be somewhere that the BIOS can load the
    initial boot program that starts the process of
    loading the operating system. The place where
    this information is stored is called the master
    boot record (MBR). It is also sometimes called
    the master boot sector or even just the boot
    sector. (Though the master boot sector should not
    be confused with volume boot sectors, which are
    different.)
  • The master boot record is always located at
    cylinder 0, head 0, and sector 1, the first
    sector on the disk This is the consistent
    "starting point" that the disk always uses. When
    the BIOS boots the machine, it will look here for
    instructions and information on how to boot the
    disk and load the operating system.

22
Disk Partition - 1
  • Master Partition Table This small table contains
    the descriptions of the partitions that are
    contained on the hard disk. There is only room in
    the master partition table for the information
    describing four partitions. Therefore, a hard
    disk can have only four true partitions, also
    called primary partitions. Any additional
    partitions are logical partitions that are linked
    to one of the primary partitions. One of the
    partitions is marked as active, indicating that
    it is the one that the computer should use for
    booting up.

23
Disk Partitions Key Observations - 1
  • What is a Partition ? A certain area or amount
    of space on a hard drive, be it 1 or 100 of the
    drives total capacity.
  • Primary Partitions A partition that is used to
    start an operating system, although you can use
    primary partitions that don't contain the
    operating system
  • Logical Partitions A partition that contains
    Data.
  • Active Partitions Any primary partition that
    has an operating system installed on it may be
    designated as the Active partition simply for the
    sake of convenience in making it the System
    partition. Active partition and System partition
    mean the same thing.
  • The boot files reside on the System partition    
    ---   The system files reside on the Boot
    partition
  • The BOOT partition usually contains the Master
    Boot Record / MBR .

24
Disk Partitions Key Observations - 2
  • There can be up to a maximum of four primary
    partitions on a single basic disk.
  • The Primary partitions do not have to come before
    Extended partitions.
  • A drive is not required to have any Primary
    partitions .
  • Any CD-ROM Drive , while it contains a blank CD,
    is not shown as containing a partition because
    there is no data contained on the CD.

25
Typical Structure of an MBR - 2
  • Master Boot Code / Boot Loader Code The master
    boot record contains the small initial boot
    program that the BIOS loads and executes to start
    the boot process. This program eventually
    transfers control to the boot program stored on
    whichever partition is used for booting the PC.

26
Importance of the MBR
  • Any corruption / erasure / change in MBR may make
    the whole Disk UNUSABLE.

27
From Power on to Boot up on a PC - 11
  • 13. The BOOT LOADER code , that is a part of the
    Master Boot Record (MBR) of the Active Primary
    Partition of the chosen IPL /BOOT DEVICE , takes
    over CONTROL from the BIOS.

28
Boot Loader Structure
  • Boot loaders are small piece of code that helps
    to load the Operating System.
  • These may face peculiar constraints, especially
    in size for instance on the IBM PC and
    compatibles, the first stage of boot loaders must
    fit into the first 446 bytes of the Master Boot
    Record, in order to leave room for the 64-byte
    partition table and the 2-byte AA55h 'signature',
    which the BIOS requires for a proper boot loader.

29
Second Stage Boot Loader ( Multiple O.S.)
  • The MBR , in this case, contains a
    second-stage boot loader, such as NTLDR, LILO or
    GRUB.
  • This second stage BOOT LOADER will then be able
    to load the operating system proper depending on
    the users response , and finally transfer
    execution to it.
  • Subsequently the system will initialize itself,
    and may load device drivers and other programs
    that are needed for the normal operation of the
    OS.

30
BOOT.ini File
  • The Bootable O.S. Selector Menu for WINDOWS
    environment.
  • Stored in the very first Primary Active
    Partition ( C for a Hard Disk Drive).

31
Cold Start vs. Warm Start
  • This process is called a "cold boot" (since the
    machine was off, or cold, when it started). A
    "warm boot" is the same thing except it occurs
    when the machine is rebooted using
    CtrlAltDelete or similar. In this case
    the POST is skipped and the boot process
    continues roughly from the step 8 onwards.

32
Boot Process Time
  • The boot process is considered complete when the
    computer is ready to interact with the user or
    the operating system is capable of running
    ordinary applications. Typical modern PCs boot in
    about a minute (of which about 15 seconds are
    taken by the preliminary boot loaders, and the
    rest by loading the operating system), while
    large servers may take several minutes to boot
    and to start all services - to ensure high
    availability, they bring up some services before
    others.
  • Most embedded systems must boot almost instantly
    -- for instance, waiting a minute for the
    television to come up is not acceptable.
    Therefore they have their whole operating system
    in ROM or flash memory, so it can be executed
    directly.

33
The BOOT Process Summary - 1
  • On power on CPU is directed to a specific/fixed
    address ( BIOS ROM address) which usually
    stores a Power On Self Test (POST) Program..
  • After executing the POST stored in BIOS ROM, the
    CPU searches for the designated Boot Device in a
    pre specified Order as stored in the Set-Up
    information ( Non Volatile but User Alterable
    Area of main Memory) .
  • After locating a pre-fixed valid Boot Device, the
    CPU is directed to a specific Area of that BOOT
    Device (usually the 0th Sector of the Primary
    Hard Disk).
  • That area contains the BOOT Loader Code within
    the MASTER BOOT RECORD (MBR).

34
The BOOT Process Summary - 2
  • 5. This MBR Code is read into the Main Memory
    and executed.
  • 6. On Execution this MBR Code may load the a
    2nd Level BOOT Loader ( For Multi Boot System)
    stored in the neighborhood place into Main
    Memory.
  • 7. This 2nd Level Boot Loader (like LILO or
    GRUB) contains entry points to the various
    Operating System along with provision for the
    User to choose the designated Operating System as
    well as a default O.S. that will start after a
    specified Time Interval.
  • 8. Relevant Portion of the Chosen / Selected
    Operating System is then LOADED into the main
    memory.

35
Post Boot Up Scenario A
  • The overall system control is taken over by
    the main memory resident Operating System(O.S.).
  • 1. The O.S. Command Interpreter / Graphic User
    Interface starts executing. At this point only
    the KERNEL / O.S. / Supervisor Process is running
    , which first loads the User Code / PASSWD File
    into the Kernel Data Area in the Electronic Read
    Write Memory . Then it starts WAITING for user
    response via the Log In process.
  • 2. User selects Log In Option either through
  • Keyboard or Mouse that sends an Interrupt
    to the System in response the System displays the
    USERCODE Screen. Still O.S. process is executing
    waiting for User to type in the User Code.
  • 3. User starts typing in the user code via
    keyboard . Each key press sends an Interrupt to
    the system that causes the following.

36
Post Boot Up Scenario B
  • 5. The running O.S. / Kernel / Supervisor Process
    recognizes and services that interrupt in the
    following manner
  • a) Receives the Key Code from the Keyboard
    Interface Buffer into the KERNEL Area of the Read
    Write Memory.
  • b) Locates the Display Font corresponding to
    the stored key code .
  • c) Sends that Display Font to the Display
    Interface for displaying on the screen.
  • d) All these steps a), b) c) are repeated
    for each key press till user presses ltEntergt /
    ltReturngt Key. On pressing Return Key the
    following events take place.

37
Post Boot Up Scenario C
  • 6. The running O.S. / Kernel / Supervisor Process
    recognizes and services that interrupt caused by
    User pressing the RETURN / ENTER Key in the
    following manner
  • a) Receives the Key Code from the Keyboard
    Interface Buffer into the KERNEL Area of the Read
    Write Memory.
  • b) Composes all the Previous Characters
    pressed by the User as user code (stored in the
    Kernel Area of Read Write Memory) into a String .
  • c) Searches for a match for that string in the
    User code list stored as a part of User code /
    Password Block in the KERNEL Data Area.
  • d) If it DOESNOT find a match then displays
    the message like INVALID USERCODE TRY AGAIN and
    WAITS for new user code to be typed in .
  • e) On finding a match / getting a valid User
    code the resident running O.S. process asks for
    PASSWD . It accepts and handles user typed in
    password in exactly the same manner as in the
    case of user code.

38
Post User Log In
  • The very first User Process gets created . This
    becomes the PARENT user process.
  • B. This parent user process needs to create
    other processes to proceed further.
  • C. The User Process is running currently.
  • D. The user can now create other threads by
    opening new WINDOW.
  • E. Next user types in the Command to invoke the
    EDITOR . This command is handled in exactly the
    same way as the earlier User code and Pass Word
    till the PARSING ( Command Recognition) phase.
  • F. Subsequently it loads the Editor Code from the
    Disk to Memory , creates the EDITOR process , and
    sets it running as a CHILD Process to the user
    process.

39
Editor Process Running
  • 1. User types in the Source Code via Keyboard
    which gets stored in the EDITOR Buffer
  • ( Read Write Memory) .
  • 2. Subsequently this Buffer can be saved as a
    Source file on Secondary Media (like DISK) based
    on User command. The EDITOR process uses File
    System commands which in turn employs Disk Write
    Routine to achieve this.
  • 3. Editor Process is still running can be
    closed / put to background by the User.
  • N.B Secondary Media already contains the
    relevant translator program (Compiler) for the
    selected HLL in Executable (.EXE ) form.
  • 4. The User creates another Window and gives
    COMPILE Command.

40
Post Compilation Command - 1
  • 5. Compiler and Source File brought into main
    memory (in parts if needed) from secondary store
    (Disk) by the KERNEL / O.S. running as a service
    within the logged in user process employing
    memory management File System Calls Disk Read
    Routine in response to the compile command.
  • 6. The compilation process is created as
    ANOTHER Child to the User Process, The EDITOR
    process if running, gets pre-empted from Running
    State to Ready State to make way for the
    Compilation process.
  • 7. The Compilation Process executes with source
    file as input to produce the translated assembly
    language equivalent of source. It stores this
    translated code in the Memory OR in the DISK as
    .ASM /.S file in parts within swap area if
    needed using memory management File System
    Calls Disk Write Routine. On completion
    Compilation Process is terminated i.e. it no
    longer occupies memory.
  • .

41
The Assembly Process
  • 8. Assembler executable program (Assembly
    language translator) available on disk and .ASM /
    .S file are loaded into main memory (in parts if
    needed) from secondary store (Disk) by the O.S.
    using memory management File System Call Disk
    Read Routine based on assemble directive.
  • 9. Assembler program gets executed i.e. Assembler
    Process starts running as yet another Child
    Process to convert the assembly language source
    .ASM file) to equivalent machine coded version
    (object .OBJ file) on Disk in parts if needed
    using memory management File System Call Disk
    Write Routine . On completion it also gets
    terminated.
  • .

42
Linking
  • 10. Linker module (existing on Disk) and machine
    code object (.OBJ file generated by the
    Assembler) are loaded into main memory from disk
    (in parts if needed) by the O.S. using memory
    management File System Call Disk Read Routine
    based on link command.
  • 11. Execute linker program i.e. Create Linker
    process as another child of the parent user
    process to resolve references to already existing
    system library modules and user modules. This
    converts .OBJ file to executable (.EXE)
    version/command (.COM) version and copies it onto
    disk in parts if needed using memory
    management File System Call Disk Write
    Routine . The linked libraries may / may not
    form part of the executable module ( STATIC /
    DYNAMIC Linking).
  • .

43
Loading Execution
  • 12.Bring loader module existing in disk into main
    memory.
  • 13. Execute loader module to load some portion of
    the executable version (.EXE file) into main
    memory using memory management File System Call
    Disk Read Routine . Currently however linking
    and loading phases are done together by the same
    module ( Linking Loader / Linkage Editor that
    performs dynamic linking , loading relocation).
  • 14. Execute the loaded linked program portion
    as another Child process of the User (this will
    cause the memory management part of the Operating
    System to automatically load copy back the
    remaining portions of the .EXE file from disk
    into main memory on demand using the File System
    Call Disk Read / Write routine to obtain
    result.

44
Various Execution Environment
  • In most cases the steps starting from
    compilation of the Source File to loading the
    executable file into main memory are either
    combined in a BATCH File to form a single step.
    This is known as compile and go / translate and
    go.
  • In LINUX / UNIX the steps of COMPILATION (
    TRANSLATING High Level Source to ASSEMBLY Code) ,
    ASSEMBLING ( ASSEMBLY Code to Equivalent Machine
    Coded Version Object File ) , LOADING Machine
    Object File DYNAMICALLY LINKING libraries are
    combined in a Batch File.
  • When the executable code is brought into main
    memory it is in effect brings in the code first,
    then subsequently during execution it
    occupies/uses some more memory locations to store
    data and status , creates uses Stack , as well
    as employs some CPU registers and also may use
    some other resource (peripheral/file). This
    executable image of any program is termed as a
    process.

45
The Next Phase
  • What Code gets Executed ? The Machine Code.
  • High Level Code ? Assembly Level Code ? Machine
    Level Code. EXAMPLE ?
Write a Comment
User Comments (0)
About PowerShow.com