hpc lecture11

Upload: taran-aulakh

Post on 14-Apr-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 HPC Lecture11

    1/23

    High Performance Computing

    Lecture 11

    Matthew Jacob

    Indian Institute of Science

  • 7/27/2019 HPC Lecture11

    2/23

    2

    Agenda1. Program execution: Compilation, Object files, Function call

    and return, Address space, Data & its representation (4)2. Computer organization: Memory, Registers, Instruction set

    architecture, Instruction processing (6)

    3. Virtual memory: Address translation, Paging (4)

    4. Operating system: Processes, System calls,Process management (6)

    5. Pipelined processors: Structural, data and control hazards,impact on programming (4)

    6. Cache memory: Organization, impact on programming (5)

    7. Program profiling (2)

    8. File systems: Disk management, Name management,

    Protection (4)9. Parallel programming: Inter-process communication,

    Synchronization, Mutual exclusion, Parallel architecture,Programming with message passing using MPI (5)

  • 7/27/2019 HPC Lecture11

    3/23

    3

    Computer Organization: Hardware

    CacheMemory

    I/O

    Bus

    I/OI/O

    MMU

    ALU Registers

    CPU

    Control

  • 7/27/2019 HPC Lecture11

    4/23

    4

    Computer Organization: Software

    Hardware resources of computer system are

    shared by programs in execution

    Operating System: Special software that

    manages this sharing

  • 7/27/2019 HPC Lecture11

    5/23

    5

    Operating Systems (OS)

    Examples

    Unix

    Linux

    Apple Mac OS Microsoft Windows

    Google Chrome OS

    AIX, HP-UX, Solaris

    Fedora, openSUSE, Ubuntu, Debian

    Mac OS X Snow LeopardWindows 7, Vista, XP

  • 7/27/2019 HPC Lecture11

    6/23

    6

    Computer Organization: Software

    Hardware resources of computer system are

    shared by programs in execution

    Operating System: Special software that

    manages this sharing Process: A program in execution

    i.e., present in main memory and being executed

    On Unix systems, you can use ps to get

    information about the current status of processes

    % ps

    Shell prompt

  • 7/27/2019 HPC Lecture11

    7/23

    7

    Computer Organization: Software

    Hardware resources of computer system are

    shared by programs in execution

    Operating System: Special software that

    manages this sharing Process: A program in execution

    Shell: A command interpreter, through which

    you interact with the computer system

    Examples of Unix shells: csh, bash

    A program; just another program

  • 7/27/2019 HPC Lecture11

    8/23

    8

    % ps

    PID TTY TIME CMD

    15459 pts/10 00:00:00 bash

    15491 pts/10 00:00:00 ps

  • 7/27/2019 HPC Lecture11

    9/23

    9

    % ps -a

    PID TTY TIME CMD

    6358 pts/4 00:00:00 pine15538 pts/10 00:00:00 ps

    20252 pts/2 00:00:01 pine

    31066 pts/5 00:00:01 emacs-x

    31072 pts/5 00:00:00 xterm

    31084 pts/5 00:00:00 xdvi-xaw3d.bin

    % ps -l

    F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD

    0 S 539 15459 15458 0 76 0 - 16517 wait pts/10 00:00:00 bash

    0 R 539 15539 15459 0 78 0 - 15876 - pts/10 00:00:00 ps

  • 7/27/2019 HPC Lecture11

    10/23

    10

    Cache

    Memory

    I/O

    Bus

    I/OI/O

    MMU

    ALU Registers

    CPU

    Control

    Operating System, Processes, Hardware

  • 7/27/2019 HPC Lecture11

    11/23

    11

    Operating System, Processes, Hardware

  • 7/27/2019 HPC Lecture11

    12/23

    12

    Operating System, Processes, Hardware

    Hardware

    Processes

    System Calls

    Operating System

  • 7/27/2019 HPC Lecture11

    13/23

    13

    Operating System, Processes, Hardware

    Hardware

    Processes

    System Calls

    OS Kernel

  • 7/27/2019 HPC Lecture11

    14/23

    14

    System Calls

    How a process gets the operating system todo something for it

    Interface or API (Application Programming

    Interface) for interaction with the operating system

  • 7/27/2019 HPC Lecture11

    15/23

    15

    System Calls

    How a process gets the operating system todo something for it

    Interface or API (Application Programming

    Interface) for interaction with the operating system

    Examples: Operations on files creat(): to create a new file

    unlink(): to remove a file

    open(): to open a file for reading and/or writing

    read(): to read data from an open file into a variable

    write(): to write data into an open file

    lseek(): to change the current pointer into the open file

  • 7/27/2019 HPC Lecture11

    16/23

    16

    System Calls

    How a process gets the operating system todo something for it

    Interface or API (Application Programming

    Interface) for interaction with the operating system

    Examples: Operations on processes fork(): to create a new process

    Terminology: parent process calls fork() which

    causes a child process to be created

    Both parent and child processes continue toexecute from that point in the program

  • 7/27/2019 HPC Lecture11

    17/23

    17

    System Calls

    How a process gets the operating system todo something for it

    Interface or API (Application Programming

    Interface) for interaction with the operating system

    Examples: Operations on processes fork(): to create a new process

    exec(): to change the memory image of a process

    e,g, to change the program that a process is

    executing

  • 7/27/2019 HPC Lecture11

    18/23

    18

    fork( ) and exec( )

    text

    data

    heap

    stack

    Parent Process Child Process

    text

    data

    heap

    stack

    retval = fork();if (retval == 0) {

    /* child */

    } else {/* parent */

    }

    exec();

  • 7/27/2019 HPC Lecture11

    19/23

    19

    text

    data

    heap

    stack

    text

    data

    text

    Parent Process Child Process

    stack

    fork( ) and exec( )

  • 7/27/2019 HPC Lecture11

    20/23

    20

    System Calls

    How a process gets the operating system todo something for it

    Interface or API (Application Programming

    Interface) for interaction with the operating system

    Examples: Operations on processes fork(): to create a new process

    exec(): to change the memory image of a process

    exit(): to terminate

    wait(): to make parent sleep until child terminates

  • 7/27/2019 HPC Lecture11

    21/23

    21

    System Calls

    How a process gets the operating system todo something for it

    Interface or API (Application Programming

    Interface) for interaction with the operating system

    Examples: Operations on memory sbrk: can be used by malloc() to increase size of

    the heap

  • 7/27/2019 HPC Lecture11

    22/23

    22

    System Calls

    How a process gets the operating system todo something for it

    Interface or API (Application Programming

    Interface) for interaction with the operating system

    Examples: Operations on files, processes,memory, etc

    When a process is executing in a system call,

    it is actually executing Operating System

    code

  • 7/27/2019 HPC Lecture11

    23/23

    23

    Operating System, Processes, Hardware

    Hardware

    Processes

    System Calls

    Operating System