Index

SchoolNotes

  1. CS225
    1. OOP
      1. Inheritance
      2. R-Value References
    2. Misc Notes
    3. Size/Offsets of Structs/Classes
    4. Week 4
  2. CS200
    1. Introduction
    2. Scan Conversion
    3. Quiz 01
  3. GAM200
    1. Notes
  4. CS180
    1. Introduction
    2. Midterm Revision
    3. Finals Revision
    4. Memory
    5. ELF Format
    6. History of Computers
    7. Stuff to Research
    8. Quiz To-Do
    9. OS Architectures
    10. Week 3
    11. Week 4
    12. Week 5
    13. Week 6 (Threads)
    14. Week 7 (Scheduling)
    15. Week 8 (Thread Scheduling)
    16. Week 9 (Memory Management)

Memory

A program is loaded into memory, with the instructions being executed one by one - But what loads the program instructions into the memory?

To get the address of the actual instructions, print out main (after a reinterpret_cast to a void pointer), which is the function pointer of the main function cycle.
Run the same program twice and it will result in the same location because it was started at a different time. BUT they're stored in different areas. Why? Because of virtual address spaces where in the RAM, there are two separate portions of memory for the first and scond pointer.

--------------------

Memory Regions



Text, Data, Stack, Heap

Heap is low address, Stack is high address
Low address = smaller number

Stack grows downwards towards the lower address,
Heap grows upwards towards the higher address

Lower address - 0x00000000
Higher Address - 0xFFFFFFFF

The Memory Region addresses for Text and Data are determined at link-time.
Stack and heap addresses are determined by the operating system.

--------------------


Layout of an executable


Main Header, Program Header, Text Segment, Data Segment, String table

Main header -> How many sections, address of start instruction etc
Program Header -> How much memory neeeded
Text Segment -> Code
Data -> Global variables
String Table -> List of IDs, values and captions for all strings in the application.

char *s = “Hello”; //string table
char s1[] = “Hello”; //stack? or string table, not sure

--------------------

Big-endian and little-endian are terms that describe the order in which a sequence of bytes are stored in computer memory. Big-endian is an order in which the "big end" (most significant value in the sequence) is stored first (at the lowest storage address).


EXAMPLE OF STORAGE:

0x12345678

big endian:
12 34 56 78

litttle endian:
78 56 34 12

--------------------

Boot-Up Process

/Boot Sequence

1. Power-On (Hardware up and running)
2. Run BIOS (Basic I/O System)
◇ BIOS is a chip that can be found on the mother board.
◇ It is separate from the CPU and RAM
◇ BIOS is actually accessed via a hard-coded address, which indicates the starting of the BIOS. The BIOS is stored in flash memory, in ROM (read only memory).
◇ Search through the secondary storages (ie hard disks for bootable drive)
3. BIOS load and run a power-on self-test (POST) to check if the BIOS is uncorrupted, then checks for each hardware peripheral and initializes them then loads and runs the Master Boot Record
◇ The Master Boot Record (MBR) is the information in the first sector of any hard disk or diskette that identifies how and where an operating system is located so that it can be boot (loaded) into the computer's main storage or random access memory.
◇ The MBR holds the information on how the logical partitions, containing file systems, are organized on that medium. The MBR also contains executable code to function as a loader for the installed operating system—usually by passing control over to the loader's second stage, or in conjunction with each partition's volume boot record (VBR). This MBR code is usually referred to as a boot loader.
◇ Small 512 bytes (may be different, not sure)
◇ Any bootable media - SSDs, USBs, CD-ROMs - have MBRs
4. MBR may load boot loaders (chain-loading) for different OSs.
5. Load and run OS

--------------------

What does an OS do?
- Interface/Abstraction
→ API for programmers
→ Remove need for low-level details.
- Portability
- Resource Management
→ Virtualization
- Security