An Introduction to Computer Hardware Using Linux ================================================ Slide 2: It's About Knowledge ----------------------------- I'll begin with the first page of chapter 1 of the Apple II Users Manual. This is the third sentence. "Remove the lid of the Apple by prying the back edge until it 'pops', then pull straight back on the lid and lift it off. This is what you'll see:" Thank you Christopher Espinosa In the Apple IIe manual had similar instruction... after taking off the lid what did you do? Install a disk drive! On page 2! That is AWESOME! Hands-On Imperative Levy described in Chapter 2, "Hackers believe that essential lessons can be learned about the systems—about the world—from taking things apart, seeing how they work, and using this knowledge to create new and more interesting things." Applies to hardware and software. Computers are not like cars. With a car, you can be a fairly proficient driver without actually knowing much at all about car mechanics. With a computer, one can never be a proficient user without some understanding of how the hardware (the physical components) and the software (the programs) interact. Any computer training that does not take this into account provides a limited knowledge which is easily forgotten and provides no avenues for further knowledge. In other words, it's pretty useless. Unfortunately t his seems to be how most so-called professional computer training companies teach. Evidently, they want you to return to services (and pay) time and time again. http://www.mfac.gov.tp/manual/chapter101e.html (Many images are from that document) Slide 3: The System Unit and Standard Peripherals ------------------------------------------------- We can start with the system unit, the "box" that sits on the desk. Many people erroneously call this the "hard disk", but the hard disk is only one component of the system unit, which consists of the power supply, motherboard, CPU, RAM, hard disk, peripheral controllers etc. Standard input and standard output refer to the basic input (typically the keyboard and mouse) and output devices (the monitor); in operating system terms is also refers the preconnected input and output channels between a computer program and its environment. Standard input is data (often text) going into a program. The program requests data transfers by use of the read operation. Not all programs require input. For example, the dir or ls program (which displays file names contained in a directory) performs its operation without any stream data input. Unless redirected, input is expected from the keyboard which started the program. Standard output is the stream where a program writes its output data. The program requests data transfer with the write operation. Not all programs generate output. For example the file rename command (variously called mv, move, ren) is silent on success. Unless redirected, standard output is the terminal which initiated the program. Standard error is another output stream typically used by programs to output error messages or diagnostics. It is a stream independent of standard output and can be redirected separately. It is acceptable—and normal—for standard output and standard error to be directed to the same destination, such as the text terminal. Slide 4: The Case/Chassis and Power Supply ------------------------------------------ The case or chassis is the box that houses the motherboard, power supply and other components of the system unit. When purchased separately to the rest of the components it invariably comes with a power supply included. Case/Chassis come in three styles - desktop (more long than high), tower (more high than long) and mini-tower. Out of the three styles, the desktop does have some advantages over the tower - it's easier to add and remove components, and Processor fans have been known to fall off the Processor in tower cases. But many people prefer the tower case because of space efficiency. Another critical feature of the case/chassis is that the size determines the type of Motherboard that can be installed. As an electrical device a computer obviously needs power to work! The power supply provides the necessary voltage for operation to the motherboard with leads to requisite components (hard disk drive, DVD). Often a much underrated part of the computer system. Having a power supply with an extremely low leakage, capable of resisting damage from spikes, brownouts and outages etc should be a key consideration when choosing a computer system. A cheap power supply that delivers the improper voltage can cause serious damage to a computer system. The single biggest cause of breakage and failure in computers is thermal damage. When a computer is turned on, it gradually warms up the entire system, causing components to expand. When you turn the system off, the computer cools down and the components shrink. The more this happens, the greater the opportunity for breakage. Solder cracks, heat sink adhesives weaken, wires break, chips crack and manner of problems occur. Linux has support for ACPI (Advanced Configuration & Power Interface, an abstraction layer between the OS and platform firmware and hardware. The ACPI Component Architecture (ACPICA) project provides an OS-independent reference implementation of the ACPI specification. Power management for computer systems has matured over the years and several standards exist. The two popular ones are advanced power management (APM) and advanced configuration and power interface (ACPI). APM is a standard proposed by Microsoft and Intel for system power management, and it consists of one or more layers of software to support power management. In the APM model, BIOS plays a key role. ACPI is the newer of the two technologies, and it is a specification by Toshiba, Intel and Microsoft for defining power management standards. ACPI allows for more intelligent power management, as it is managed more by the OS than by the BIOS. Power Management Linux http://www.linuxjournal.com/article/6699 Slide 5: The Motherboard ------------------------ Modern motherboards typically include, at a minimum: sockets (or slots) in which one for microprocessors may slots into which the system's main memory is to be installed a chipset which forms an interface between the CPU's front-side bus, main memory, and peripheral buses non-volatile memory chips (usually Flash ROM in modern motherboards) containing the system's firmware or BIOS a clock generator which produces the system clock signal to synchronize the various components slots for expansion cards power connectors fans and heat sinks Nearly all motherboards include connectors to support commonly used input and outpyt devices, such as PS/2, USB etc The Computing Form Factor specifies the physical dimensions of major system components. ATX (Advanced Technology eXtended) is a motherboard form factor specification developed by Intel in 1995, improving standardisation. Most modern ATX motherboards have five or more PCI or PCI-Express expansion slots, while microATX boards typically have only four. Mini-ITX is a 17 x 17 cm low-power motherboard form factor developed by VIA Technologies. BTX (for Balanced Technology Extended) is a form factor for motherboards, originally intended to be the replacement for the aging ATX motherboard form factor in late 2004 and early 2005. However, future development of BTX retail products by Intel was canceled in September 2006. Many companies now use proprietary form factors. Slide 6 : Processor (Central Processing Unit) --------------------------------------------- The CPU: Attached to a motherboard socket the processor performs the basic arithmetical, logical, and input/output operations of the system according to program requirements. Usually include an arthimetic logic unit (ALU) and a control unit (CU), which manages memory, decoding, and execution. Not all computational systems rely on a central processing unit. An array processor or vector processor has multiple parallel computing elements, with no one unit considered the "center". In the distributed computing model, problems are solved by a distributed interconnected set of processors. On old large machines, CPUs require one or more printed circuit boards. On personal computers and small workstations, the CPU is housed in a single chip called a microprocessor. Since the 1970's the microprocessor class of CPUs has almost completely overtaken all other CPU implementations. Modern CPUs are large scale integrated circuits in small, rectangular packages, with multiple conecting pins. The main specifications of a processor is the speed of operation and the "width" of operation. The speed of a processor is the simpler concept. Measured in gigahertz (billions of cycles per second), the faster the processor, the better it is. The "width" of a processor consists of three main quantities - the number of internal registries, the size of the data input and output bus and the size of the memory address bus. The internal registry determines the size of the data the chip can deal with internally. The data bus width determines the size of data the chip can transfer in and out. The memory address determines the maximum size of memory that the chip can send and receive data. Furthermore, a processor usually has internal cache memory, which provides temporary high access speed memory space. e.g., 64-bit CPU and ALU architectures are those that are based on registers, address buses, or data buses of that size. However, a CPU might have external data buses or address buses with different sizes from the registers, even larger (the 32-bit Pentium had a 64-bit data bus, for instance). Subscalar processers are very inefficient! Alternatives include instruction level and thread-level parallelism. The former increase the rate that instructions are executed, the latter increases the number programs that are executed. Processing performance of computers has been further increased by using multi-core processors, added two or more individual processors ("cores") into one integrated circuit. The former increase the rate that instructions are executed, the latter increases the number programs that are executed. Instruction level parallelism (ILP) seeks to increase the rate at which instructions are executed within a CPU (that is, to increase the utilization of on-die execution resources), and thread level parallelism (TLP) purposes to increase the number of threads (effectively individual programs) that a CPU can execute simultaneously. One of the simplest methods used to accomplish increased parallelism is to begin the first steps of instruction fetching and decoding before the prior instruction finishes executing. This is the simplest form of a technique known as instruction pipelining, and is utilized in almost all modern general-purpose CPUs. This separation can be compared to an assembly line, in which an instruction is made more complete at each stage until it exits the execution pipeline and is retired. Another strategy of achieving performance is to execute multiple programs or threads in parallel. This area of research is known as parallel computing. Multiple Instructions-Multiple Data or MIMD. One technology used for this purpose was multiprocessing (MP). The initial flavor of this technology is known as symmetric multiprocessing (SMP), where a small number of CPUs share a coherent view of their memory system. A further elaboration is multi-threading; a single program might have several threads (or functions) that could be executed separately or in parallel. Why is AMD skipping from K8 to K10? They were afraid K9 would be a dog. Slide 7: Basic Input/Output System (BIOS) ----------------------------------------- Boot Firmware: The BIOS is the first code run by a PC when powered, initialising core devices (video, keyboard, mouse, HDD, DVD) and locating the operating system. BIOS, a general term, includes all drivers in a system that act as an interface between the hardware and the software in the system. It includes the motherboard BIOS, BIOS ROM on adapter cards, and BIOS loaded into the computer's memory from disk (device drivers). Although it seems to be distant and far too deeply embedded for user concerns, some understanding of a computer's BIOS is essential concept to understanding the computer as a whole. It really is the link between the hardware and software of a system and includes a very important component which most users have had some experience with - device drivers. What confuses people is that the core of the BIOS is a nonvolatile ROM component on the motherboard, but this isn't all of what it consists of. BIOS, a general term, includes all drivers in a system that act as an interface between the hardware and the software in the system. It includes the motherboard BIOS, BIOS ROM on adapter cards, and BIOS loaded into the computer's memory from disk (device drivers). If one things of a computer in a series of layers (and we'll return to this conceptual model in the next chapter) the following is illustrative. The key features to understand is that applications talk to operating systems via an Application Program Interface, operating systems talk to hardware via BIOS and device drivers. Whilst the interaction between the operating system and the BIOS is the same, the connection between the BIOS and the hardware differs (as different machines have different hardware). The BIOS on the motherboard contains the device drives for the most basic components of the system; the keyboard, the floppy drive, the hard disk drive, the input/output ports and so forth. Obviously, most of these become operational soon after the computer is turned on. The same applies for some adapter card BIOS ROM, such as video adaptors, SCSI adaptors, Network adaptors, and IDE expansion adaptors. In modern PCs the BIOS is stored in rewritable memory, allowing the contents to be replaced or 'rewritten'. This rewriting of the contents is sometimes termed flashing. This can be done by a special program, usually provided by the system's manufacturer, or at POST, with a BIOS image in a hard drive or USB flash drive. A file containing such contents is sometimes termed 'a BIOS image'. A BIOS might be reflashed in order to upgrade to a newer version to fix bugs or provide improved performance or to support newer hardware, or a reflashing operation might be needed to fix a damaged BIOS. A BIOS may also be "flashed" by putting the file on the root of a USB drive and booting. Nonvolatile BIOS memory refers to a small memory on PC motherboards that is used to store BIOS settings. It was traditionally called CMOS RAM because it used a low-power Complementary metal-oxide-semiconductor (CMOS) SRAM powered by a small battery when system power was off. The term remains in wide use but it has grown into a misnomer: nonvolatile storage in contemporary computers is often in EEPROM or flash memory (like the BIOS code itself); the remaining usage for the battery is then to keep the real-time clock going. The typical NVRAM capacity is 512 bytes, which is generally sufficient for all BIOS settings. The CMOS RAM and the real-time clock have been integrated as a part of the southbridge chipset and it may not be a standalone chip on modern motherboard. The memory and real-time clock are generally powered by a CR2032 lithium coin cell. These cells last two to ten years. Coreboot: Used to be called LinuxBIOS, is a free software project which seeks to replace proprietary BIOS firmware with a minimalist system; proprietary BIOSes are considered large, complex and inefficient. Coreboot simply copies the kernel to RAM, jumps to the entry point and let's Linux do the rest of the hardware initialisation. Copy the Linux kernel from flash to RAM Jump to the Linux kernel entry point Let Linux do the rest of the hardware initialization Use a full Linux system to load the OS Slide 8: Random Access Memory and Read Only Memory -------------------------------------------------- Usually this refers to the memory, or more specifically the Random Access Memory (RAM), that holds all the programs and data that the processor is using at a given time. It can differentiated from Read Only Memory (ROM) which usually can't be modified or disk memory (also known as storage). RAM is dynamic memory; information can be sent to the RAM any number of times and volatile - very importantly, as we all have experienced losing work in this way - it is only stored whilst there is electricity in the system. The quantity of memory is measured in bytes - usually megabytes on current machines. Having a higher amount of memory on your computer allows the machine to run more programs, more sophisticated programs and manipulate more data. ROM is worth discussing very briefly. It is incorrect to view ROM as somehow being very different to RAM (this is reason it's being discussed here). ROM is simply RAM that (usually) can't be written to nor is the data volatile. In terms of architecture it is very much the same however. ROM is invariably used for the BIOS (Basic Input/Output System) - the first program that a computer loads when the power is turned on. There are two basic types of RAM, DRAM (Dynamic RAM) and SRAM (Static RAM). The former is more common as it is inexpensive and capable of a higher memory capacity on each chip. A slight disadvantage is that because the memory cells are tiny capacitors they require to be constantly refreshed with electrical charge. This takes away processor time from other tasks, and in older machines it could take up to 10-15% of CPU time. With modern CPUs running at the speed of hundreds and even thousands of megahertz, this is no longer a real problem. The advantage of DRAM is its structural simplicity: only one transistor and a capacitor are required per bit, compared to six transistors in SRAM. Static random-access memory (SRAM), unlike dynamic RAM (DRAM), does not need to be periodically refreshed, as SRAM uses bistable latching circuitry to store each bit. SRAM exhibits data remanence, but is still volatile in the conventional sense that data is eventually lost when the memory is not powered. This does not mean that Static RAM is out of the picture however. Its role has just come quite specialized. Static RAM is about thirty times as expensive and thirty times larger than DRAM. But it does have one great advantage - speed. Like the speed of a processor is measured in megahertz, the speed of memory is expressed in nanoseconds - a billionth of a second, or about the time it takes a beam of light to travel the distance of a standard ruler (megahertz and nanoseconds however can be converted via a simple formula). Basically, DRAM is too slow to fully take advantage of the speeds that modern processors can run at. So computer architecture often places SRAM in the processor cache to make better use of the CPU clock cycle. In computing, a computer bus operating with double data rate transfers data on both the rising and falling edges of the clock signal. This is also known as double pumped, dual-pumped, and double transition. The simplest way to design a clocked electronic circuit is to make it perform one transfer per full cycle (rise and fall) of a clock signal. This, however, requires that the clock signal changes twice per transfer, while the data lines change at most once per transfer. When operating at a high bandwidth, signal integrity limitations constrain the clock frequency. By using both edges of the clock, the data signals operate with the same limiting frequency, thereby doubling the data transmission rate. The primary benefit of DDR3 SDRAM over its immediate predecessor, DDR2 SDRAM, is its ability to transfer data at twice the rate (eight times the speed of its internal memory arrays), enabling higher bandwidth or peak data rates. With two transfers per cycle of a quadrupled clock, a 64-bit wide DDR3 module may achieve a transfer rate of up to 64 times the memory clock speed in megabytes per second (MB/s). 1. RAM vs ROM vs Storage: Which memory do you remember? RAM is Random Access Memory, that holds all the programs and data that the processor is using at a given time. It can differentiated from Read Only Memory (ROM) which usually can't be modified or disk memory (also known as storage). 2. Static RAM versus Dynamic RAM. There are two basic types of RAM, DRAM (Dynamic RAM) and SRAM (Static RAM). The former is more common as it is inexpensive and capable of a higher memory capacity on each chip. SRAM is used in the processor cache. 3. Double data rate (DDR). Transfers data on both the rising and falling edges of the clock cycle. Four levels of DDR RAM. DDR4 will be released next year. Slide 9: Hard and Optical Drives -------------------------------- Hard Disk Drive: High capacity non-volatile storage for the operating system, applications and user-data. Rigid platters on a spindle, information written to sectors in parallel tracks. A hard disk drive is a high capacity memory storage system. A hard disk drive is a sealed item within the system unit. Like a floppy disk, the memory storage is nonvolatile and remains even when the power is switched off from the computer. It is invariably where the operating system, applications and most users' data is stored as well. As such, a hard disk drive error is considered very serious. Not in a technical sense of course. Even in a worse case scenario it's simply a case of pulling out the drive and replacing it with a new one. But in terms of the human frustration that comes with lost data it is possibly the most serious thing that could go wrong with a computer. A hard disk drive contains a set of rigid (hence 'hard') disk platters which cannot be removed (hard disks are sometimes called 'fixed disks'). A number of read-write heads move across the platters in the same way that a floppy disk drive works. The platters are usually made of aluminum or glass with a thin layer of magnetic material (oxide or film). Hard disks spin at about 3,600 revolutions per minute - about ten times as fast as a floppy disk. Like floppy disks, information is written to tracks which are divided into sectors of 512 bytes each and where parallel tracks and sectors make up a cylinder. As you would imagine however, their capacity is much greater than that of a floppy disk. A contemporary hard disk can easily store up to 100K of data on a single track and can have up to 10,000 or more tracks per centimetre. Unlike floppy disk drives, the heads of hard disk drives do not touch the platters. When the power is turned off, in most drives the heads land (usually gently!) on the platters as they stop spinning. When there is a sudden power failure however - as we commonly experience in the Ministry - the heads can crash against the disk as it is spinning at full speed. Called a 'head crash', this can be very damaging to the hard disk. Usually it will destroy a number of programs or data. Sometimes it can ruin the entire disk. A hard disk drive however requires a low level format, an optional partitioning procedure, and a high level format. The low level format divides the disk's tracks into sectors and creates gaps between the sectors. Partitioning the hard disk enables it to support separate file systems. these file systems are also different to those used by Linux. These file systems are established in the high level format of the hard disk. Optical Drive: Most common is a DVD Drive; same size as a CD, a 118 millimetre polycarbon disc coated with a metallic strata (usually aluminum alloy) and another polycarbon layer. The top of the disc is usually labeled as all reading occurs from the bottom - optical disks are single sided. The metallic strata is where the CD-Drive reads the information on the CD. A low-powered laser strikes the strata and a light receptor determines whether it is reflected or absent. This binary state is transformed into data or sound. Optical drives are not as fast nor can they hold as much information as a magnetic fixed hard disk system. Many users think that because they are hard, CDs require less care. This is not the case - as an optical medium, scratches, fingerprints etc. can make a CD difficult to read. Dirt and dust in the CD Drive can clog up the mechanisms and collect on the lens leading to complete failure. CDs should be handled carefully and both CDs and CD Drives should be cleaned regularly with a clean cloth and an alcohol-based cleaner. Clean the disk (carefully!) from the center to the edge, so that if any scratches arise from cleaning at least they'll be across the tracks rather than along them. The future of optical media is undoubtedly the DVD (Digital Versatile Disk), which has an initial storage of 4.7 gigabytes on a single-sided disc the same size as a Compact Disc. Current models of DVD are also compatible with 8.5 gigabyte dual-layer discs and double-sided DVD's that will store 17 gigabytes. DVD is evolving and as such, there are few standards apart from the DVD reading technology. The various types of CD Drives are connected to a SCSI or IDE/APATI interface, the parallel port or USB (Universal Serial Bus). The former consist of both slot and tray loading, whereas the latter are all tray loading drives. Whilst slot loading drives appear more "high tech", they are more difficult to repair. There is also the regrettable tendency for users to try to force floppy disks into the CD ROM slot which is annoying to repair and has a high probability of causing significant damage to the CD Drive. Slide 10: Video and Audio Hardware ---------------------------------- Video Hardware: Two major components in each, the VDU (e.g., CRT or LCD) and the video controller (on-board or card) and the speakers and sound card (on-board or card). The controller acts is an interface between the system and the peripheral. Can include own BIOS, processor, memory, driver etc. Video Hardware: Video hardware consists of two components. The monitor, or Visual Display Unit, that sits on top of the system unit (or alongside in the case of the tower and minitower chassis) and the video card or adapter, that resides in the system unit attached to the motherboard. The adapter acts as an interface between the computer and the monitor and includes its own Video BIOS, a processor, memory and driver, along with a digital to analog converter. Over time, there has been a steady increase in the resolution and colours of monitors. The main four in use today are VGA (Video Graphics Array), SVGA (Super VGS), XGA (Extended Graphics Array), and UVGA (Ultra VGA). LCDs are low glare, completely flat screens and consume about 1/20th of the power of a CRT monitor (5 watts vs 100 watts). The colour quality is considered superior. However, they also cost a little more than twice the amount of a similar CRT monitor - but in the long run however they are most cost-efficient. In a LCD, a polarizing filter creates two light waves, blocking out those not aligned with the filter. A second filter, by changing the relative angle to the first, changes the amount of light that can be passed through. In a colour LCD each filter has three cells for each pixel - red, green and blue. By 2008, worldwide sales of televisions with LCD screens had surpassed the sale of CRT units. Device Drivers: A computer program allowing higher-level computer programs to interact with a hardware device. When a calling program invokes a routine in the driver, the driver issues commands to the device; a translator between a hardware device and the applications or operating systems that use it. Typically, the logical device driver (LDD) is written by the operating system vendor, while the physical device driver (PDD) is implemented by the device vendor. But in recent years non-vendors have written numerous device drivers, mainly for use with free and open source operating systems. Slide 11: Input/Output Ports ---------------------------- Serial and Parallel: Typically associated with different types of peripheral hardware. Serial was asynchronous in 9 and 25 pin standard. Parallel ports, in comparison, typical for printers to a PC were initially one-way. The name 'parallel' port comes from the fact that they have eight lines for sending one bit of data (one byte total) simultaneously. Serial, or communications (COM), ports were originally used for devices that communicated bidirectionally with the computer. Whilst new parallel ports allow bidirectional communication, serial ports are still used for devices such as modems, mice, scanners and so forth. Serial ports are asynchronous, meaning that no clocking signal is set, so data can be sent with any time spacing. 'Serial' means that the data is sent over single wires, one for transmission and one for reception. Serial ports come in 9 and 25 pin standards, with a Universal Asynchronous Receiver/Transmitter (UART) chip responsible for converting parallel data within a PC into serial data and converting serial data when received in parallel data. Some modem manufacturers have recently introduced Enhanced Serial Ports (with the ridiculous acronym, ESP) and Super High Speed Serial Ports (which are called Super ESP). Parallel ports, in comparison, are usually used for connecting printers to a PC. Originally such ports were one way only (after all, it is rare that your computer needed information from a printer!), but modern parallel ports can send and receive data. The name 'parallel' port comes from the fact that they have eight lines for sending one bit of data (one byte total) simultaneously. Standard bidirectional parallel ports are capable of transmitting and receiving about 150kb/second - many modern machines have an Enhanced Parallel Port (EPP), a standard developed by Intel and others that operates at almost 2mb/second. USB is an external peripheral bus standard that eliminates the needs to install cards into the computer and saves system resources such as interrupts (IRQs). USB peripherals can be automatically recognized and configured as they are physically attached, eliminating the need to reboot or run a setup. USB and Firewire are two new serial port standards that far outstrip the capabilities of serial and parallel ports and may in time entirely replace them. Whilst parallel may appear quicker, transmitting multiple bits simultaneously, there are limits due to what is called 'skew' and 'jitter'. The former is the tendency for some bits to reach their destination before others. The latter is the tendency for bits to remain within the target voltage longer than necessary. With serial this problem doesn't exist. Contemporary serial technology has only depended on the capacity of the clocking rate to send the bits. Furthermore, at high speeds, parallel signals tend to interfere with each other. This doesn't happen with serial because the data transmitted and data received wires are distinct. Finally, for the reasons just noted, serial is capable of transmission and reception over far greater distances than parallel. Slide 12: Hardware and Your Linux System ---------------------------------------- Your Hardware (GUI): On the GUI use GNOME Device Manager (install, System | Tools) or System > Preferences && Administration. Or with KDE use KMenu -> Applications -> System -> System Monitor. Your Hardware (command line): /proc/cpuinfo, /proc/filesystems, /proc/kmsg, /proc/meminfo; df -h; free; /sbin/lspci, /sbin/lsusb, dmesg, dmicode /sbin/lspci will show all the pci hardware (including usb bridges,agp cards etc) /sbin/lsusb will show all the usb devices (mice,etc) dmesg will show you the kernel messages which can show you all the devices the kernel has found (hard disks,cdroms,etc) cat /proc/cpuinfo Model name, MHz, flags and more for all CPUs on a node cat /proc/filesystems Filesystems on a node cat /proc/uptime Uptime of a node in seconds cat /proc/kmsg Messages output by the kernel (typically limited by permissions). cat /proc/loadavg The load average of the system for the last 1, 5 and 15 minutes. cat /proc/meminfo Information about memory usage, both physical and swap. cat /proc/modules Loaded kernel modules. cat /proc/mounts Mounted filesystems cat /proc/net/arp Kernel ARP table. cat /proc/partitions Table of partitions known to the system