Operating System Services, Application Software and Character Encoding
IB Computer Science · Computer Organization
What the operating system does, and for whom. Applications never touch hardware directly; every file read, every pixel drawn, every packet sent goes through the operating system. That is why it carries a fixed list of responsibilities you should be able to name and explain: memory management (allocating RAM to programs and keeping them out of each other's space); processor scheduling (deciding which process runs next); the file system (organising storage into files and folders with permissions); device management (drivers that translate generic requests into commands for a specific printer or disk); the user interface; security (users, passwords, access rights); and multitasking (switching between programs fast enough to appear simultaneous). A question that asks for a function wants the function and what would go wrong without it.
Hiding complexity. The most examinable idea about operating systems is that they present a simple picture of a complicated machine. A physical disk with platters and sectors appears as a drive letter and a folder tree. RAM plus a region of disk appear as one large, continuous virtual memory. Thousands of printer models appear as one Print command, because the driver does the translation. A Java program sees a single virtual machine rather than the real processor, so the same code runs on any hardware. Each abstraction lets application programmers and users ignore detail they do not need — at the cost of some performance and of not knowing what is really happening when something goes wrong.
Application software. Word processors, spreadsheets, databases, browsers, email, graphics and computer-aided design each solve a class of user problems and share common features: a graphical interface, toolbars, menus, dialogue boxes, and — the point examiners like — common features that reduce learning, so that Save or Undo works the same way in every program. Applications are chosen by fitness for purpose, cost, compatibility with existing data and hardware, and support, not by feature count.
Characters are numbers. A computer stores only bits, so every character is a code. ASCII uses 7 bits for 128 characters: uppercase A is 65, lowercase a is 97, the digit 0 is 48, space is 32. Uppercase and lowercase differ by exactly 32, one bit, which is why case conversion is a single bit flip. ASCII has no Vietnamese, no Chinese, no accents; Unicode assigns over 140 000 codes covering every script, and UTF-8 stores them in one to four bytes, so Vietnamese text takes more space than English. Because digits are characters with their own codes, comparing numbers stored as strings goes wrong: "10" sorts before "9" because the character 1 is less than the character 9. Hexadecimal is a shorthand for binary — each hex digit is exactly four bits, so 1010 1111 is AF — used for memory addresses, colours and MAC addresses because it is compact and converts trivially. The machine does not store hex; hex is for human eyes. Underlying all of this: the same bit pattern is a number, a character, a colour or an instruction depending only on how the program reading it chooses to interpret it.
Worked example: Example 1 — explaining a sorting error and a display error using character codes
A program sorts a list of student IDs read from a file and gives the order: 1, 10, 11, 2, 3. The same program displays the name "Nguyễn Văn Ế" as "Nguy?n V?n ?". Explain both and state how to fix them.
Solution
Error 1 — comparing strings instead of numbers. The student IDs are read from the file as strings of characters, and the program sorts in character order. String comparison goes from left to right: "10" and "2" are compared at the first character, and the character 1 (code 49) is smaller than the character 2 (code 50), so "10" comes before "2" regardless of what follows. The order 1, 10, 11, 2, 3 is dictionary order, entirely correct for strings — the program is not wrong, it does the wrong job correctly. Fix: convert the IDs to integers before sorting, or if the IDs must be strings, pad with zeros to a fixed length (01, 02, 10, 11) so that dictionary order coincides with numeric order.
Error 2 — wrong character encoding. The name is stored in Unicode (UTF-8), in which ễ, ă and Ế are codes above 127 and take two or three bytes per character. The program reads the file and interprets each byte as 7-bit ASCII or another 8-bit encoding; bytes with no meaning in that encoding are replaced with a question mark. The unaccented letters display correctly because their codes are below 128 and the same in every encoding — that is the diagnostic clue. Fix: declare the correct UTF-8 encoding when opening the file and when displaying; if the original file was saved in the wrong encoding, it must be exported again from the source.
The general lesson. Both errors share the same root: the same sequence of bytes is interpreted in two ways. In error 1, the bytes of "10" are treated as two characters rather than a number; in error 2, the three bytes of one Vietnamese letter are treated as three separate characters. Data does not know what it is by itself — the program decides.
Worked example: Example 2 — converting hex and binary and calculating memory size
(a) Convert 2C hex to binary and decimal. (b) Convert 1101 0110 to hex. (c) A memory address is written with 6 hex digits; what is the maximum number of bytes of memory if each address points to one byte? (d) Why use hex instead of writing binary directly?
Solution
(a) 2C. Each hex digit is four bits: 2 = 0010, C = 12 = 1100, so 2C = 0010 1100. Decimal: 2 × 16 + 12 = 44. Check from the binary: 32 + 8 + 4 = 44.
(b) 1101 0110. Split into two groups of four bits from the right: 1101 = 13 = D, 0110 = 6. The result is D6. A common mistake is to split the groups from the left when the number of bits is not divisible by four — always split from the right and pad with 0 on the left if needed.
(c) Six hex digits. Each hex digit is four bits, so 6 digits = 24 bits. The number of addresses = 224 = 16,777,216, that is 16 MiB when each address is one byte. A quick way to answer: 166 = 224. This question connects with the address bus in lesson 1: a 24-bit bus addresses exactly this much.
(d) Why hex. A 24-bit address written in binary is 24 characters of 0 and 1 that are very easy to misread; written in hex it is only 6 characters. Because each hex digit is exactly four bits, conversion in both directions can be done by eye without calculating — something decimal lacks, because 10 is not a power of 2. That is why hex appears in memory addresses, color codes (#FF8800 is three bytes: red, green, blue) and MAC addresses. It must be stated clearly in the answer: the machine does not store hex, it stores only bits; hex is the way humans write bits compactly.
Common mistake
Trap 1 — stating an operating system function without saying what happens without it. Examiners want the function together with its consequence: without memory management, programs overwrite one another.Trap 2 — saying the computer stores hex. The machine stores only bits; hex is a way of writing for people, each digit exactly four bits.
Trap 3 — treating ASCII and Unicode as the same. ASCII is 7 bits, 128 characters, no Vietnamese; Unicode has over 140,000 codes, and UTF-8 uses one to four bytes.