When you turn on the power to a computer, the first program that runs is usually a set of instructions kept in the computer's firmware called the boot ROM. For a typical PC, this can be the basic input output system (BIOS), or on newer machines, the unified extensible firmware interface (UEFI). This code examines the system hardware to make sure everything is functioning properly and in the case of UEFI, that the boot software is legitimate and secure. Once the test has successfully completed, the firmware continues the boot process. Show
The bootstrap loader, or boot loader, is a small program that has a single function: It loads the operating system into memory and allows it to begin operation. In the most basic form, the bootstrap loader sets up the small driver programs that interface with and control the various hardware subsystems of the computer. It sets up the divisions of memory that hold the operating system, user information and applications. It establishes the data structures that hold the myriad signals, flags and semaphores that are used to communicate within and between the subsystems and applications of the computer. Then it turns control of the computer over to the operating system. The operating system's tasks, in the most general sense, fall into several categories:
These tasks define the core of nearly all operating systems. Next, let's look at the tools the operating system uses to perform each of these functions.
The CPU is the heart of the computer. A program is a sequence of instructions stored in main memory. When a program is run, the CPU fetches the instructions and executes or follows the instructions. The fetch/decode/execute cycle
Every program ends up as a sequence of basic instructions that consist of arithmetic and logic operations and control flow operations. Arithmetic and logic operations include add, subtract, multiply, divide and comparison of values (equality, less than, greater than). Control flow operations are used to determine what instruction to execute next. For example, based on the instruction, the program may skip or branch to another part of the instructions list. You will learn the details of how CPUs process instructions in CS 271, Computer architecture and assembly language.
Main memory or RAM is used to store the program while it is executing and to store the data that the program is working with. RAM details
Secondary storage provides long lasting and persistent storage. Unlike RAM, data stored within secondary storage does not disappear when a computers is turned off or restarted. The most common form of secondary storage for large computers is a disk drive but computers can use other forms of secondary storage such as solid state drives which use memory chips that maintain data values without power. Like main memory, secondary storage also stores information as sequences of 0s and 1s as bits and bytes.
We typically think of keyboards and mice but input devices can include cameras, microphones, and many other types of various sensors when you start thinking of computers embedded in cars, electronics, and almost any electrical device.
The information a computer sends to the outside world is called output. If a person is involved, output is typically sent to an output device such as the computer screen or a printer. Not all programs will output data to an output device. Instead, the output may be sent out over a computer network or stored in a database.
Questions for todayCPU - Machine Code"Software" is the general category of code which runs on the hardware. If the hardware is a player piano, then the software is the music. The common case is a "program" like Firefox -- software you run on your computer to solve a particular problem. A computer can run multiple programs at the same time and is responsible for keeping their memory separate. A CPU understands a low level "machine code" language (also known as "native code"). The language of the machine code is hardwired into the design of the CPU hardware; it is not something that can be changed at will. Each family of compatible CPUs (e.g. the very popular Intel x86 family) has its own, idiosyncratic machine code which is not compatible with the machine code of other CPU families. What is a Program/App?The machine code defines a set of individual instructions. Each machine code instruction is extremely primitive, such as adding two numbers or testing if a number is equal to zero. When stored, each instruction takes up just a few bytes. When we said earlier that a CPU can execute 2 billion operations per second, we meant that the CPU can execute 2 billion lines of machine code per second. A program, such as Firefox, is made up of a sequence of millions of these very simple machine code instructions. It's a little hard to believe that something as rich and complicated as Firefox can be built up out of instructions that just add or compare two numbers, but that is how it works. A sand sculpture can be rich and complicated when viewed from a distance, even though the individual grains of sand are extremely simple. How Does a Program Run?The CPU runs instructions using a "fetch-execute" cycle: the CPU gets the first instruction in the sequence, executes it (adding two numbers or whatever), then fetches the next instruction and executes it, and so on. Some of the instructions affect the order that the CPU takes through the instruction sequence. For example, an instruction might direct the CPU to jump back to an earlier point in the instruction sequence (loops are implemented this way), or to skip over the next instruction if a particular condition is true (if-statements are implemented this way).
How Does a Program Start?In the file system, a file like Firefox.exe just contains the bytes of the machine code instructions that make up the program (".exe" is a windows convention to mark a file as a program). Each machine code instruction takes up about 4 bytes, and whole program is just an enormous sequence of instructions. When the user double clicks a program file to run it, essentially the block of bytes of the instructions for the program are copied into RAM, and then the CPU is directed to begin running at the first instruction in that area of RAM. What Starts Firefox Running? The "Operating System"The "operating system" of a computer is like a first, supervisory program that begins running when the computer first starts up ("boots up"). The operating system plays an invisible administrative and bookkeeping role behind the scenes. When a laptop or phone starts up, the operating system typically gets things organized and then launches a "file explorer" program which displays available programs and menus etc. that show the user what is available, allowing the user to navigate and run programs. The operating system keeps things organized in the background so that multiple programs can run at the same time, which is known as "multitasking". The operating system gives each program its own area of memory, so each program only accesses its own resources .. attempting to limit what an erroneous or malicious program can do. Keeping the programs separate is sometimes known as "sandboxing" .. mediating the access of each program so it operates independently, without interfering with other programs or the system as a whole. Similarly, each program has some access to the screen through a window, but this output area is separated from the output of other programs. Recall that a .exe file or whatever is essentially just a file of machine code instructions. When you double-click the program, the operating system "launches" the program, doing the housekeeping steps of allocating an area of memory within RAM for the program, loading the first section of the program's machine code into that memory, and finally directing the CPU to start running that code. The Whole Picture - ScenariosNow we have the whole picture of a program running on the hardware. Look at common scenarios. 1. Normal Running Programs2. Program Exits Normally3. Program Stuck/Infinite Loop - Abnormal Exit4. Running Out Of Memory5. Memory Access Error6. RebootWhy is it called Reboot? |