UNIT 4 COMPUTERS - 19 SOFTWARE PDF
Document Details
Uploaded by EvocativeChrysoprase3354
Lighthouse International School
Tags
Summary
This document introduces the concepts of computer hardware and software, including the different types of software. It describes application software, system software, and operating systems, highlighting their functions. It also discusses the role of operating systems in managing hardware and software resources.
Full Transcript
## UNIT 4 COMPUTERS ### 19 SOFTWARE Computer hardware consists of items that we can see and touch such as keyboards, disk drives and monitors. Software consists of the programs that make the hardware function and also carry out tasks for the users. #### SUBJECT VOCABULARY - software: the set of...
## UNIT 4 COMPUTERS ### 19 SOFTWARE Computer hardware consists of items that we can see and touch such as keyboards, disk drives and monitors. Software consists of the programs that make the hardware function and also carry out tasks for the users. #### SUBJECT VOCABULARY - software: the set of programs run by a computer system - application software: software that performs a task that would otherwise be done by hand, perhaps with pen and paper - operating system: software designed for particular hardware and which manages other programs' access to the hardware - utility software: software that does a useful job for the user that is not essential to the operating system and not the reason for using a computer in the first place - system software: operating system and utility software #### LEARNING OBJECTIVES - Know what an operating system is and how it manages files, processes, hardware and the user interface - Understand the purpose and functions of utility software (managing, repairing and converting files; compression; defragmentation; backing up; antivirus, anti-spyware) - Understand how software can be used to simulate and model aspects of the real world - Understand what is meant by system software and application software Computer systems consist of both hardware and software. Software is the set of programs that run on a computer system. You can usefully divide software into two types. The first type is what you normally think of as programs, those that do a job for us that would otherwise have to be done by hand, such as writing a document or creating and using a spreadsheet. This is **application software**. The other kind of software is there to help us use the computer and the application programs, such as providing the user interface and tools to manage the hardware. This is **system software** and it is usually divided into operating systems and utility software. ### OPERATING SYSTEMS The operating system (OS) is usually loaded when the computer starts up. You will probably already know several operating systems, for example Microsoft Windows®, Linux®, Android, iOS®, etc. Why do you need this software? Unlike embedded systems, a general-purpose computer can be used to do a range of jobs. Software written for general-purpose computers needs to be able to run on a range of different hardware. For example, your favourite web browser runs on your laptop or desktop computer and also on your mobile phone or tablet. One of the jobs of an operating system is to manage whatever input and output devices the computer has. A programmer writing an application uses simple commands, e.g. OpenFile, and the operating system deals with exactly how to open a file. This will depend on what sort of secondary storage the file happens to be on. You might have realised this is yet another example of abstraction. This system means applications have to be written for a particular operating system but will work on any hardware. You will probably already be familiar with this idea because you know, for example, that Android apps run on any Android device. Many different models of smartphone or tablet will run the app, but the same apps won't run on your friend's iOS phone. **Figure 4.16** The operating system sits between the hardware and the programs | | | | |---|---|---| | Word | Utility | Web | | Processor | Program | Browser | | | | Image | | | | Editor | | | Operating System | | | Hardware | #### SUBJECT VOCABULARY - application programming interface (API): code that allows two programs to communicate with each other - scheduling: the algorithm that the OS uses to allow each running process to use the CPU - paging: the algorithm the OS uses to move programs from RAM to disk and back again when needed once main memory is full #### GENERAL VOCABULARY - illusion: pretence **Did You Know?** The operating system provides developers of application programs like word processors with a set of commands such as OpenFile or DisplayJPEG. This set of commands is usually called an application programming interface or API. Using the operating system API rather than accessing hardware directly means that an application program will run on the operating system. It doesn't matter what hardware it is installed on. It also means that the operating system controls what application programs are allowed to do. This helps to reduce the risk of programs crashing and to maintain security. In general, managing files and the directory structure, and input/output, is one of the important jobs of the operating system. An operating system also shares access to the hardware among the different programs that are running (and on some operating systems among the different users who are logged on to the computer). Two important pieces of hardware that have to be shared are the CPU and RAM. In the chapter on hardware, you learned that a von Neumann system does only one thing at a time. When you have several applications open, they can't really run at the same time. The operating system keeps up this **illusion** by allowing each program to use the CPU for a short time before switching to the next program. This is called **scheduling**. It is possible to load many applications all at the same time and each uses some memory. What if you keep loading applications until RAM is full? In this case the operating system creates another illusion, by moving programs from RAM to disk and back again when needed. This is called **paging**, swapping or virtual memory. You might notice this as a lot of disk activity. Your computer might run more slowly when lots of applications are open. As well as the applications you are running, the operating system is also running other programs in the background. They include various parts of the operating system itself such as the programs that manage the network, the scheduler and also any hardware drivers and utility programs such as anti-virus. Each task that is running is called a process. To see all the processes that are running, including the invisible ones: - on Microsoft Windows, press CTRL-ALT-DEL and choose Task Manager - on Linux, type `~ps aux~` at the command prompt - on OS X, run the Activity Monitor from Applications/Utilities. ### 19 SOFTWARE #### SUBJECT VOCABULARY - concurrent: processes that run at the same time are described as being concurrent - authentication: the process of proving to a computer system who you are (e.g. using a username and password) - user interface: the way the user interats with the operating system Information about how much the hardware is used by each process is displayed, including: - the proportion of the CPU time spent on this process - the amount of memory used by this process - the amount of available memory (real memory and virtual memory, VM). These processes are running one at a time, being given their share of the CPU time by the scheduler. They are all running alongside one another, but not really at the same time, so we say they are running **concurrently**. An operating system that allows processes to run **concurrently** is called a multitasking operating system. Almost all modern operating systems work this way. As well as allowing multitasking, some operating systems allow different users to use the hardware. In some cases, only one user can use the hardware at once (**single user**). In others, several users can be sharing the hardware (**multi-user**). Your smartphone is an example of a single-user system, while your school network servers will be running a multi-user operating system. This is so that many of you can log on at the same time. In a multi-user system, each user has to identify themselves (with a username, fingerprint, etc.) and provide a password (or other login) to prove they are who they say they are. This is called **authentication**. Authority to use the facilities of the computer system is based on who you are. For example, learner users might not be able to print, while tutor users can. In such systems there is usually also a super-user (sometimes called administrator or root) who can access all resources and also control the access rights of other users. The operating system also provides and runs the user interface. Sometimes this is a graphical user interface (GUI) with windows, icons, menus and pointers (WIMP) like Microsoft Windows or MacOS. Sometimes it is just a text, command-line interface (CLI) like MS DOS. The choice of user interface depends on the applications a computer is expected to run. An embedded system might not have an operating system as such: therefore, it does not have a user interface. A computer acting as a web server might only need a command-line interface because it is intended only ever to be managed by technicians. A computer used for video editing will almost certainly need a graphical user interface. **Did You Know?** In common with many school subjects, as you learn more about computer science you will discover that some details were missed out so that you could understand the key ideas first. At least in computer science you are used to the idea of abstraction. One such detail is the idea of a driver. The driver for a device is the software that really communicates with the I/O device on the computer's bus. It transfers data between the hardware device and the operating system in an agreed format - also known as the application programming interface (API). To find out more about drivers and operating systems search online for 'NDIS' - this is the API that is used for Microsoft Windows network drivers - or 'ALSA', the API for sound drivers on Linux. An API is yet another example of abstraction. A software developer deals with the essential tasks like OpenFile, but the detail of how data is taken from secondary storage is hidden, managed by the operating system. ### ACTIVITY 21: OPERATING SYSTEMS AND SCHEDULING 1. Run/open the program that lists the running processes on an operating system you are familiar with. Make a table listing the application software, utility software and operating system processes that are running. 2. There are several different algorithms that operating systems can use for scheduling. The one described on page 189 is called 'round-robin' scheduling. Research and describe at least one other method used for scheduling. 3. Take one of the programs you have already written. Add a feature to save or load data using the operating system API. ### UTILITY SOFTWARE #### ACTIVITY 22: UTILITY SOFTWARE Make a list of all the utility software you can find on your computer. Try to organise your list into groups or categories such as 'file management tools'. Pair with a partner and share your list. Make a 'problems' list of software that you cannot agree a category for. Finally, pair with another couple of learners and compare their problem list with yours. #### SUBJECT VOCABULARY - back-up: a copy of files in another location so that they are still available if the original copy is damaged or lost. Backing up is the process of making a back-up copy #### GENERAL VOCABULARY - multimedia: consisting of more than one medium, e.g. sound, text, images, animation, film Utility software is software that does a useful job for the user. It is: * not essential to the operating system * not the reason for using a computer in the first place (i.e. it is not application software). Utility software, sometimes called tools, can be split into three areas: * basic tools * file management * security. #### BASIC TOOLS Basic tools include things like a simple text editor (e.g. Notepad or nano), calculator, command prompt, hex editor and software for accessibility, such as for producing large print. They are usually included as part of the operating system. #### FILE MANAGEMENT TOOLS No matter how much storage you have, somehow you always manage to fill up the space with files. This brings problems such as not being able to find your favourite photos, losing files if there is a fault and things simply running slower on your computer. File management tools include software to keep your data secure by making a **back-up** copy of your files in another location. Some programs can recover files that have been deleted or repair files that might be damaged or have errors. Another useful file management tool is for converting files between different formats. This is especially useful for multimedia files where there are a large number of common formats (e.g. jpg, gif, png). #### HINT Be careful not to confuse compression with encryption. #### SUBJECT VOCABULARY - defragmenter: a utility that moves file clusters on a disk so they are closer to each other in order to speed up disk access - virus: software that is designed to make and distribute copies of itself. This is usually for a malicious purpose - spyware: software, possibly a virus, that is designed to be installed secretly on a computer. It records private information as the user enters it - firewall: a utility that controls program access to the network, both incoming and outgoing #### GENERAL VOCABULARY - cluster: a group of things together that are of the same type - malicious: intentionally harmful Another important file management tool is a **defragmenter** which is used to speed up access to data stored on magnetic hard disk drives. Files are not stored on disk in one large chunk. They are stored in smaller pieces called sectors or clusters and a single file's clusters can be spread across the disk. Accessing these fragmented files can be slow, so a defragmenter moves the bits of files around, so they are closer together, speeding up disk access (at least in theory). Note that, unlike magnetic disk drives, solid state/flash drives do not require defragmentation (i.e. what is done by a defragmenter) as access times are the same across the entire volume. You can also use a file management tool to compress the files you don't use very often. This frees up space on the disk, but those compressed files are then slower to access as they have to be uncompressed to open them. #### SECURITY TOOLS Security tools include anti-malware programs such as antivirus and anti-spyware software. Computer viruses and spyware can be used to capture private information, to introduce a process on your computer to do a job for the attacker, such as send out spam email, or to crash an important machine such as a web server. Some are simply written to annoy users. This software is called a virus because it copies itself and spreads: antivirus tools try to identify code that copies itself and prevent those processes from running. **Firewall** software controls your connection to a network, deciding which network data can flow to and from your computer. This can help to prevent infection by viruses. **Encryption** software is used to make files unreadable without a password. Data on your tutor's laptop might be encrypted so that it is not understandable if the laptop is stolen. ### SIMULATION AND MODELLING #### SUBJECT VOCABULARY - 'what if?' question: running a computer model with a given set of inputs to see what the model produces as an output or prediction - heuristic: a type of algorithm capable of finding a solution to a problem quickly and easily. This is done through trial and error and educated guesswork to cut corners and remove less likely alternatives. Heuristic algorithms don't always find the best solution, but they will usually find one that works - Monte Carlo method: carrying out a statistical analysis of a number of random samples to get approximate solutions to a problem. The larger the number of samples used, the more accurate the result is likely to be - neural networks: process information in a similar way to human brains and learn and adapt over time. This makes them useful tools for recognising faces, identifying illnesses and quality control, for example. Computers are normally not very good at these things #### GENERAL VOCABULARY - atmospheric: of the atmosphere surrounding the earth - trial and error: a way of solving a problem by trying different methods and learning from mistakes In Unit 1 you learned about how you can use abstraction to model the real world. By now you will be getting used to the idea of abstraction as a central part of computer science. It means hiding complexity, only exposing the key features of a situation and leaving out the details. Computer science allows us to do experiments that can't (or shouldn't be) done in the real world. For example: - you can't increase the average temperature of the Earth to see what happens to our weather - you shouldn't stop one of a pair of twins from exercising to see if it causes depression. You can, however, write a computer program to model or simulate these situations and see what results you get. Scientists, engineers, economists and other experts can ask 'what if?' questions using computer models. For example, what if the bridge were twice as long? There are two big problems with this approach: 1. The model or simulation includes assumptions. It is not reality, so the answers might not be right. 2. The real world is far too complicated to allow for every possible factor in your model. So, you have to use abstraction to simplify it. This makes it even less likely that you will get a completely right answer. However, computer models can reveal some interesting things about how the world works or about how humans work with machines. #### EXAMPLES OF COMPUTER MODELS A flight simulator allows pilots to train to fly aircraft safely. They can make mistakes in the simulator without endangering their own lives or the lives of passengers. Commercial flight simulators use a moveable cabin and real flight controls so pilots can see, hear and feel things just as if they were flying a real aircraft. If you ever watch the weather forecast, you will sometimes hear the presenter talking about their computer and sometimes even about computer models. The atmospheric models used to forecast the weather are some of the most complex pieces of software that exist. They split the atmosphere up into small pieces and keep track of the temperature, pressure, humidity and other factors in each piece. They start the model with real measurements, then they let it calculate the effect each piece of atmosphere has on its neighbours and see how the weather patterns develop. Another example of a computer model is used for earthquake prediction. Unlike the previous examples, we don't know the mathematics behind how earthquakes work. Models like these have to use information from past examples and **probability** to come up with best guesses as to what might happen and when. Some common techniques used in such models are heuristics, Monte Carlo methods and **neural networks**. There is a whole field of computer science devoted to finding patterns in data and using them to predict the future: this is **machine learning**. #### SKILLS - Reasoning - Problem Solving ### ACTIVITY 23: CREATING A SIMULATION 1. Using a programming language that you are learning: - create a simulation of rolling a die. The die must come up with 1 to 6 with equal probability. - adapt your program so that the die is biased to give 6 more often than it should. 2. In a group, research techniques used in machine learning and illustrate your findings using presentation software. Bring your talks together and present them back to the class. ### CHECKPOINT #### STRENGTHEN - **S1** What is meant by 'machine code'? - **S2** What is the function of an assembler? - **S3** What is the job of a translator? - **S4** Momina is a C# programmer and uses a compiler. Denis is a Python programmer and uses an interpreter. What challenges will Momina face in developing software compared with Denis? #### CHALLENGE - **C1** What is the difference between high-level and low-level programming languages? - **C2** Evaluate the choice of translator between compilers and interpreters. How confident are you in your answers to these questions? If you are not sure that you answered them well, you could review the chapter by searching online. ### SUMMARY * CPUs can only run programs written in machine code. * A translator is a program that converts source code into machine code. * Humans program computers mostly using a range of high-level languages, but sometimes in assembly language (a low-level language). * An assembler is used to translate assembly language mnemonics into machine code. * Compilers and interpreters are types of translator, each having their own advantages and disadvantages. ### 20 PROGRAMMING LANGUAGES An algorithm can be written in any language that a human can understand. Unfortunately, computers can only understand instructions written as a series of 1s and Os in a language called machine code. Machine code is too difficult for humans to use. So, we code programs in other languages, which can then be translated into machine code for the computer. #### LEARNING OBJECTIVES - Understand what is meant by high-level and low-level programming languages and understand their suitability for a particular task - Understand what is meant by an assembler, a compiler and an interpreter when translating programming languages and know the advantages and disadvantages of each #### LOW-LEVEL PROGRAMMING LANGUAGE #### SUBJECT VOCABULARY - instruction set: the list of all possible commands a particular CPU knows how to carry out - machine code: the binary codes representing each of the instructions in the instruction set - translator: a program that converts source code into machine code - source code: the text of the program that a programmer writes - assembler: translates the mnemonics of assembly language programs into machine language instructions for the microprocessor to carry out - assembly language: a low-level language written using mnemonics - low-level programming language: a programming language that is closely related to the CPU's machine code You learned earlier that a von Neumann architecture computer uses the stored program concept. The instructions that the computer carries out, the program, are stored in memory just like any other kind of data. This means that programs are also just binary numbers - that's all you can store in memory. So how can binary numbers represent a program? One other thing you learned is that the CPU can only do a few simple things. It only 'understands' a few very simple instructions. Complex things like playing games are possible because a really large number of those simple things happen very fast. Those few simple instructions that a CPU knows how to do are called the **instruction set** for that type of CPU. Each instruction is given a binary code. It is these codes that make up your programs. The binary codes representing a program are called **machine code**. A machine code program would look something like the diagram below. You can probably see why programming in machine code would be completely impractical. `0110100100100101010101011111010101100101011010110101010` **Figure 4.17** An example of a machine code program Not only would it be incredibly difficult to work out the sequence of 1s and Os you need, but also your program would only work on that kind of CPU. This is because different CPUs have different instruction sets. Instead, you need a **translator** which converts your programs into the CPU's machine code language. **Translators** are also programs. Their input is the text of your program - this is called your **source code**. Their output is machine code which the CPU can run (execute). The simplest translator is called an **assembler**. It converts **assembly language** to machine code. **Assembly language** is called a low-level programming language. #### SUBJECT VOCABULARY - mnemonic: a short, simple acronym that represents each of the instructions in a CPU's instruction set, e.g. LDR (load register), STR (store) and CMP (compare) - emulator: hardware or software that allows one type of computer system to behave like another - reboot: to start a device again, e.g. turn off the computer and turn it on again This is because the programmer is working at the lowest level of detail, the level of the CPU hardware itself. Each instruction in assembly language is the same as a machine code instruction. Assembly language is a bit easier to work with than machine code because each instruction is written as a short, memorable keyword called a **mnemonic**. For example, the instruction for the CPU to add numbers together might be 01101001 in machine code but is just ADD in assembly language. The assembler replaces each mnemonic with the appropriate binary machine code and data. Here is an example of assembly code: `LDR R3, [R1]` `MQV R2, #0` `CMP R3, RO` `MOVGT R2, #1` #### SKILLS - Reasoning **Did You Know?** The 1980s space-trading game Elite, which featured 3D graphics and a galaxy of hundreds of planets to explore, was written entirely in assembly language and occupied just 22 KB. To understand how amazing that programming was, look at the file size of a modern 3D graphics game. To learn more, you could play an authentic version of the game on an emulator. Search online for 'BeebEm'. Writing programs in assembly language is challenging for three reasons: 1. A very limited range of instructions is available. Every task, even the simplest, has to be built up from the smallest steps. Some older CPUs could not even multiply numbers. 2. You have to manage all your data. There are no strings, integers or real numbers, just binary, so you have to decide how to represent your data. You also have to decide and manage where it is stored in memory. 3. Debugging is very difficult. When the assembled program runs, any bugs usually just make the machine crash and you have to **reboot** to try again. Nowadays, almost no programs are written in assembly language. The exceptions are some hardware drivers and programs designed to run on embedded systems that you learned about earlier in the chapter. This is because writing in the CPU's home language can be useful if you want your program to be very small and very fast or to directly control the I/O hardware. ### ACTIVITY 24: ASSEMBLY LANGUAGE Make a list of tasks for which assembly language is better suited than a high-level programming language. ### EXTEND YOUR KNOWLEDGE Research the Little Man Computer simulation. Make a list of the machine code instructions that Little Man Computer 'understands'. ### HIGH-LEVEL LANGUAGES #### SUBJECT VOCABULARY - compiler: a translator that converts high-level language source code into object code, often machine code. The source code is translated all at once and saved to be executed later. - interpreter: a translator that converts high-level language source code into object code, often machine code. The source code is translated and executed one line at a time. - object code: the translated source code. Often this will be machine code, but might also be an intermediate code, which has to be further translated before it can be executed. It is much more common to write software in high-level programming languages such as Python, C#, Java or Visual Basic. For these programs to run on the CPU, the source code has to be translated into machine code. This can be done all at once, and the finished machine code program saved and run later, one line at a time. ### COMPILERS AND INTERPRETERS A translator that translates the whole program in one go is called a **compiler.** A translator that translates and runs your program one line at a time is called an **interpreter.** A **compiler** converts high-level language to machine code and saves the output as a machine code program, sometimes called **object code.** This usually has the .exe file extension, short for 'executable', because the machine code can be executed or run. An **interpreter** translates your source code one line at a time then runs it. There is no object code file, only your original source code. | INTERPRETER | COMPILER | |---|---| | Every computer that will run your program needs the interpreter software installed. | The output from a compiler will run on its own on any similar computer. | | Interpreters find errors when they happen and can often tell you what has gone wrong. | A compiler cannot produce any object code unless the whole program is correct - they tend to report a lot of errors initially, making it harder to debug your program. | | Programs tend to run slower using an interpreter because the interpreter has to translate the source code while the program is running. | It can be easier to protect your code from being altered or copied if it has been compiled because you only give people the object code (machine code), which is hard to understand. | #### SKILLS - Problem Solving - Reasoning - Critical Thinking ### ACTIVITY 25: GRAPHICAL VERSUS TEXTUAL LANGUAGES Implement one of the algorithms you designed in Unit 1 in a graphical programming language (e.g. Scratch®), and a textual language (e.g. Python). Which language did you find most intuitive, i.e. which was easiest to use? Which one would you recommend for someone starting to program? ### CHECKPOINT #### STRENGTHEN - **S1** What is meant by 'machine code'? - **S2** What is the function of an assembler? - **S3** What is the job of a translator? - **S4** Momina is a C# programmer and uses a compiler. Denis is a Python programmer and uses an interpreter. What challenges will Momina face in developing software compared with Denis? #### CHALLENGE - **C1** What is the difference between high-level and low-level programming languages? - **C2** Evaluate the choice of translator between compilers and interpreters. How confident are you in your answers to these questions? If you are not sure that you answered them well, you could review the chapter by searching online. ### SUMMARY * CPUs can only run programs written in machine code. * A translator is a program that converts source code into machine code. * Humans program computers mostly using a range of high-level languages, but sometimes in assembly language (a low-level language). * An assembler is used to translate assembly language mnemonics into machine code. * Compilers and interpreters are types of translator, each having their own advantages and disadvantages.