Number Sysems Ops Networking
Number Sysems Ops Networking
Number Sysems Ops Networking
Overview
This module introduces you to the subject of operating systems. It is an introductory course that
will take you approximately 30-40 hours to complete (including the exercises) depending upon
your level of prior knowledge.
Learning Outcomes
At the end of this section you should be able to
briefly explain the difference between a general purpose operating system and a
dedicated operating system
1
What does an operating system do?
An operating system controls the way in which the computer system functions. In order to do
this, the operating system includes programs that
What is a program?
A program is a set of instructions that performs a task. When we talk about programming a
computer or writing a computer program, we mean writing a set of instructions that the computer
can execute. Developers (people who write programs) need to use special software to write
programs, often called compilers.
The first task of this initialize program would be to reset (and probably test) the hardware sensors
and alarms. Once the hardware initialization was complete, the operating system would enter a
continual monitoring routine of all the input sensors. If the state of any input sensor changed, it
would branch to an alarm generation routine.
Input devices provide input signals such as commands to the operating system. These commands
received from input devices instruct the operating system to perform some task or control its
behavior. Typical input devices are a keyboard, mouse, temperature sensor, air-flow valve or
door switch. In the previous example of our simple security control system, the input devices
could be door switches, alarm keypad panel and smoke detector units.
Output devices are instruments that receive commands or information from the operating system.
Typical output devices are monitor screens, printers, speakers, alarm bells, fans, pumps, control
valves, light bulbs and sirens.
3
programs and documents, printing and accessing files.
Consider a typical home computer. There is a single keyboard and mouse that accept input
commands, and a single monitor to display information output. There may also be a printer for
the printing of documents and images.
In essence, a single-user operating system provides access to the computer system by a single
user at a time. If another user needs access to the computer system, they must wait till the current
user finishes what they are doing and leaves.
Students in computer labs at colleges or University often experience this. You might also have
experienced this at home, where you want to use the computer but someone else is currently
using it. You have to wait for them to finish before you can use the computer system.
The operating system for a large multi-user computer system with many terminals is much more
complex than a single-user operating system. It must manage and run all user requests, ensuring
they do not interfere with each other. Devices that are serial in nature (devices which can only be
used by one user at a time, like printers and disks) must be shared amongst all those requesting
them (so that all the output documents are not jumbled up). If each user tried to send their
document to the printer at the same time, the end result would be garbage. Instead, documents
are sent to a queue, and each document is printed in its entirety before the next document to be
printed is retrieved from the queue. When you wait inline at the cafeteria to be served you are in
a queue. Imagine that all the people in the queue are documents waiting to be printed and the
cashier at the end of the queue is the printer.
4
files and write programs, the operating system is generally provided with a number of utility
programs. The utilities are used for
Multithreading
Introduction
5
When the computers were first invented, they were capable of executing one program at a
time. Thus once one program was completely executed, they then picked the second one to
execute and so on. With time, the concept of timesharing was developed whereby each
program was given a specific amount of processor time and when its time got over the
second program standing in queue was called upon (this is called Multitasking, and we
would learn more about it soon). Each running program (called the process) had its own
memory space, its own stack, heap and its own set of variables. One process could spawn
another process, but once that occurred the two behaved independent of each other. Then
the next big thing happened. The programs wanted to do more than one thing at the same
time (this is called Multithreading, and we would learn what it is soon). A browser, for
example, might want to download one file in one window, while it is trying to upload
another and print some other file. This ability of a program to do multiple things
simultaneously is implemented through threads (detailed description on threads follows
soon).
As explained above, Multitasking is the ability of an operating system to execute more than
one program simultaneously. Though we say so but in reality no two programs on a single
processor machine can be executed at the same time. The CPU switches from one program
to the next so quickly that appears as if all of the programs are executing at the same time.
Multithreading is the ability of an operating system to execute the different parts of the
program, called threads, simultaneously. The program has to be designed well so that the
different threads do not interfere with each other. This concept helps to create scalable
applications because you can add threads as and when needed. Individual programs are all
isolated from each other in terms of their memory and data, but individual threads are not
as they all share the same memory and data variables. Hence, implementing multitasking is
relatively easier in an operating system than implementing multithreading.
Hey, wait!!! all that's fine but I still do not understand fully what threads are!!!
What is a thread???
That is because a full-blown process has its own memory area and data, but the thread
shares memory and data with the other threads.
A process/program, therefore, consists of many such threads each running at the same time
within the program and performing a unique task.
Threads are also called lightweight processes that appear to run in parallel with the main
program. They are called lightweight because they run within the context of the full-blown
program taking advantage of the resources allocated for the program.
In the preemptive mode, the operating system distributes the processor time between the
threads and decides which thread should run next once the currently active thread has
completed its time-share on the processor. Hence the system interrupts the threads at
regular intervals to give chance to the next one waiting in the queue. So no thread can
6
monopolize the CPU at any given point of time. The amount of time given to each thread to
run depends on the processor and the operating system. The processor time given to each
thread is so small that it gives the impression that a number of threads are running
simultaneously. But, in reality, the system runs one thread for a couple of milliseconds, then
switches to the other and so on. It keeps a count of all the threads and cycles through them
giving each of them a small amount of the CPU time. The switching between threads is so
fast that it appears as if all the threads are running simultaneously.
But, what does switching mean?? It means that the processor stores the state of the
outgoing thread (it does so by noting the current processor register values and the last
instruction-set the thread was about to perform), restores the state of the incoming thread
(again by restoring its processor register values and picking the last instruction-set where it
had left itself) and then runs it. But this style has its own flaws. One thread can interrupt
another at any given time. Imagine what would happen if one thread was writing to a file
and the other interrupted it and started writing to the same file. Windows 95/NT, UNIX use
this style of managing their programs/threads.
In cooperative mode, each thread can control the CPU for as long as it needs it. In this
implementation, one thread can starve all the others for processor time if it so chooses.
However, if a thread is not using the processor it can allow another thread to use it
temporarily. Running threads can only give up control either if a thread calls a yield function
or if the thread does something that would cause it to block, such as perform I/O. Windows
3.x uses this kind of implementation.
On some systems, you can have both the cooperative and preemptive threads running
simultaneously (Threads running with high priorities often behave cooperatively while
threads running at normal priorities behave preemptively). Since you are not sure whether
the system would let threads run in a cooperative or a preemptive model, it is always safer
to assume that preemption is not available. You should be designing your program in such a
way that processor-intensive threads should yield control at specific intervals. When the
currently running thread wants to yield it means that the thread is willing to give up CPU
control. The system then looks for threads that are ready to run and which are of the same
or higher priority as the current thread. If it finds any then it pauses the execution of the
current thread and activates the next thread, waiting in the queue. But, if it cannot find any
thread of the same or higher priority then control returns to the thread that yielded. Still if a
thread wants to give up control and let a thread of lower priority take over, then the thread
goes into a sleep mode for a certain amount of time letting the lower priority thread run.
On a multi-processor system, the operating system can allocate individual threads to the
separate processors, which thus fastens the execution of the program. The efficiency of the
threads also increases significantly because the distribution of the threads on several
processors is faster than sharing time-slices on a single processor. It is particularly useful to
have a multi-processor system for 3D modeling and image-processing.
We all have fired a print command to print something. Imagine what would happen if the
computer stopped responding while the printing is going on. Oh No!! Our work will come to
a stop till the nasty print work is going on. But as we all know, nothing like this happens.
We are able to do the normal work with the computer (like editing/saving a file) or drawing
a graphic and listening to music etc without getting bothered with the print job. Now, this is
possible because separate threads are executing all these tasks. You would have all noticed
that the database or a web server interacts with a number of users simultaneously. How are
they able to do that?? It is possible because they maintain a separate thread for each user
and hence can maintain the state of all the users. If the program is run as one sequence
then it is possible that failure in some part of the program will disrupt the functioning of the
7
entire program. But, if the different tasks of the program are in separate threads then even
if some part of the program fails, the other threads can execute independent of it and will
not halt the entire program.
Wow!! This sounds good. So, if we start writing threaded applications, we would never come
across those nasty crashes in our program.
There are numerous ways that you can design a good multi-threaded application. Here we
would get a general glimpse but as we proceed (in the later parts of this article) you would
understand things better. Threads can be of different priorities (we would see in the later
parts of this article series how to decide their priority levels). Say, we need to draw a
graphic or do a big mathematical computation and at the same time want to get user input.
We should first keep all the individual tasks (like drawing an image, or doing computation or
asking for user-input) in separate threads. We should then allocate a higher priority to the
thread, which is expecting user-input so that its responsiveness is high, and the thread,
which is drawing the graphic or doing the calculation, at a lower priority so that the entire
CPU time is not bogged down by these tasks.
Again, say based on the user-input the program has to do some processing. If the
processing is long then it may take some time to complete and the user is un-necessarily
made to wait till it is over. In such cases, we should keep separate threads, one to read
user input and the other to handle any lengthy operations based on the input. This will
make the program more responsive. It will also give the user the flexibility to cancel the
operation at any point of the running of the thread. Hence, applications that use user-input
should always have one thread to handle input, which will keep the user interface active at
all times, and let the processor-intensive tasks execute on separate threads
In the case of drawing graphics, the application should always be listening to messages (like
a repaint command) from the system. If the application gets busy doing some other work
then the screen might remain blank for a long time, which of course is not very appealing
visually. So, in such cases it is advisable to have one thread always dedicated to handling
messages (like repaint) from the underlying system.
Always remember that a thread, which manages time-critical tasks, should be given a high
priority and the others a low priority. Like the thread listening for client requests should
always remain responsive and hence allotted high priority. A user-interface thread that
manages interactions with the users should delegate all requests immediately to the worker
threads rather than trying to work on those requests. This way, it will remain responsive to
the users at all times.
8
What is software and what is application software?
Software is just another name for program. We often use the term to refer to a group of
programs. For example, you might get asked the question "what sort of software do you have?".
In this case, the person is asking you what types of software do you have, and how many
different software programs do you have. I guess you could think of someone asking a snake
collector the question "What sort of snakes do you have?". For the snake collector, they
obviously have many different types and sometimes several of the same species. Software is
similar. So you might respond to such a question by answering that you have some word
processing software such as Microsoft Word and some games such as Quake and Sim City.
Application software excludes the operating system and those programs that are part of the
operating system. In general, you buy application software for your computer. An example might
be a word processor or a reference atlas.
Entertainment/ Entertainment software is designed for you to have fun with! Its purpose
Games is to keep you entertained! This includes games software.
Examples of entertainment software are Microsoft Age of Empires
and Sim City 2000.
Utility Utility software is designed for you to perform routine tasks associated
with the storage and manipulation of your information. This includes
software such as schedulers, clocks, media players and communication
tools.
Examples of utility software are McAfee Virus Scan and Arcada
backup software.
Revision Exercise 1
9
List FOUR things an operating system does.
List THREE home appliance devices in your home that probably have an operating system
controlling their function.
List FOUR hardware devices on a typical home computer that an operating system has to
initialize when it is turned on.
List THREE possible errors that might occur in a typical home computer that an operating
system has to handle.
State THREE possible basic routines an operating system might provide for handling a hardware
device.
10
Learning Outcomes
At the end of this section you should be able to
identify the essential operations that need to be performed in order to switch from one
program to another
define the terms context switching, system overhead, time-slice, quantum period and
scheduling
Process manager
Scheduler
File manager
11
memory management
process management
inter-process communication
12
processes? The simple answer is that it doesn’t. The processor of the computer runs one process
for a short period of time, then is switched to the next process and so on. As the processor
executes millions of instructions per second, this gives the appearance of many processes
running at once.
Co-operative switching means that a task that is currently running will voluntarily give
up the processor at some time, allowing other processes to run.
Preemptive switching means that a running task will be interrupted (forced to give up)
and the processor given to another waiting process.
The problem with co-operative switching is one process could hang and thus deny execution of
other processes, resulting in no work being done. An example of a co-operative system was
Windows 3.1
Pre-emptive scheduling is better. It gives more response to all processes and helps prevent (or
reduce the number of occurrences of) the dreaded machine lockup. Windows NT workstation is
an example of such as operating system.
Note: Only 32-bit programs in Windows 95 are pre-emptive switched. 16-bit programs are still
co-operatively switched, which means it is still easy for a 16-bit program to lock up a Windows
95 computer.
A multi-user operating system allows more than one user to share the same computer system at
the same time. It does this by time-slicing the computer processor at regular intervals between
the various programs run by each user.
In this example, there are five people that share the processor hardware and main memory on a
time basis. Consider a 486 Intel processor running at 50MHz. This processor is capable of about
6 million instructions per second.
If we decided that we would share the hardware by letting each user run for 1/5th of a second,
this would mean each user could execute about 1.2 million instructions each time they have the
processor.
We start off by giving the first user (which we will call Bart) the processor hardware, and run
Barts program for 1/5th of a second. When the time is up, we intervene, save Barts program state
(program code and data) and then start running the second user program (for 1/5th of a second).
This process continues till we eventually get back to user Bart. To continue running Bart's
program, we restore the programs code and data and then run for 1/5th of a second.
13
What is dispatching?
It will be noted that it takes time to save/restore the programs state and switch from one program
to another (called dispatching). This action is performed by the kernel, and must execute
quickly, because we want to spend most of our time running user programs, not switching
between them.
What is scheduling?
Deciding which process should run next is called scheduling, and can be done in a wide variety
of ways.
14
Co-operative schedulers are generally very simple, as the processes are arranged in a ROUND
ROBIN queue. When a running process gives itself up, it goes to the end of the queue. The
process at the top of the queue is then run, and all processes in the queue move up one place.
This provides a measure of fairness, but does not prevent one process from monopolizing the
system (failing to give itself up).
Pre-emptive scheduling uses a real-time clock that generates interrupts at regular intervals (say
every 1/100th of a second). Each time an interrupt occurs, the processor is switched to another
task. Systems employing this type of scheduling generally assign priorities to each process, so
that some may be executed more frequently than others.
Revision Exercise 2
List FIVE functions that a real time executive does.
What is co-operative switching and how does it differ from pre-emptive switching?
15
What is dispatching?
What happens to the performance of running user programs when system overhead increases?
What is a time-slice?
What is scheduling?
What is one problem with First-In-First-Out queues when used to schedule processes.
16
17
Introduction to Computer Hardware
Number Systems
Binary Numbers
Having grown up with decimal number we all tend to take then for granted. However in our
study of computers we need to use number which differ from the decimal (base 10).
Lets look in detail at a decimal number system and recall the 'rules' associated with this system.
First consider the following decimal number:
136.25. What does this actually mean?
In its full incantation this number means:
102 * 1 = 100.0
101 * 3 = 30.0
100 * 6 = 6.0
10-1 * 2 = 0.2
10-2 * 5 = 0.05
total = 136.25
Now consider the binary number 1101.01. Again in its full form this means:
23 * 1 = 1000.0 (8 in decimal)
22 * 1 = 100.0 (4 in decimal)
21 * 0 = 00.0 (0 in decimal)
20 * 1 = 1.0 (1 in decimal)
2-1 * 0 = 0.0 (0.0 in decimal)
2-2 * 1 = 0.01 (0.25 in decimal)
total = 1101.01 (13.25 in decimal)
The following shows the first integers and their binary equivalents (and how they are derived):
decimal binary
18
0 0000 (0 * 23 + 0 * 22 + 0 * 21 + 0 * 20)
1 0001 (0 * 23 + 0 * 22+ 0 * 21+ 1 * 20)
2 0010 (0 * 23+ 0 * 22+ 1 * 21+ 0 * 20)
3 0011 (0 * 23+ 0 * 22+ 1 * 21+ 1 * 20)
4 0100 (0 * 23+ 1 * 22+ 0 * 21+ 0 * 20)
5 0101 (0 * 23+ 1 * 22+ 0 * 21+ 1 * 20)
6 0110 (0 * 23+ 1 * 22+ 1 * 21+ 0 * 20)
7 0111 (0 * 23+ 1 * 22+ 1 * 21+ 1 * 20)
8 1000 (1 * 23+ 0 * 22+ 0 * 21+ 0 * 20)
9 1001 (1 * 23+ 0 * 22+ 0 * 21+ 1 * 20)
0+0=0
0+1=1
1+0=1
1 + 1 = 0 (carry 1 to the next column)
For example:
01101000 +
00101001
________
= 10010001
or
11101000 +
10101001
19
________
= 110010001
Hexadecimal Numbers
Although it is very convenient for computers to use 0 and 1 (as these correspond to the
absence/presence of a voltage or current, the direction of a magnetic field i.e. north/south, etc.) it
is difficult for humans to readily identify binary numbers. Hexadecimal (Hex) can act as an
interim number system between binary and ourselves as it is more recognizable yet readily
convert to and from binary.
In the hexadecimal system 16 (rather than 10 in decimal or two in binary) symbols/digits
(number characters) are used. The hexadecimal system uses the digits 0 through 9 and the letters
A through F (uppercase or lowercase) to represent the decimal numbers 0 through 15. One
hexadecimal digit is equivalent to 4 bits, and 1 byte can be expressed by two hexadecimal digits.
For example, binary 0101 0011 corresponds to hexadecimal 53. To prevent confusion with
decimal numbers, hexadecimal numbers in programs or documentation are usually followed by
H or preceded by &H (e.g. Visual Basic), or 0x (e.g. C++).
Thus, 10H = decimal 16; 100H = decimal 162 = decimal 256.
A table providing decimal, binary, and hex equivalents for the first 16 integers is:
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
20
12 1100 C
13 1101 D
14 1110 E
15 1111 F
If we consider eight binary digits using unsigned values (as above) we can represent the range of
values from 0 to 255 (a total of 28 values). However, if we allow the right most bit in a binary
number (the Most Significant Bit - MSB) to represent the sign of
the number (i.e. 0 means a positive number and 1 means a negative number), whereas the other
seven digits represent the magnitude of the number. For example:
00000001 represents +1
10000001 represents -1
00010101 represents +21
10010101 represents -21
01111111 represents +127
11111111 represents -127
Although these signed integers have solved the problem of representing positive and negative
values they do not lend themselves to binary arithmetic that are performed using 'logic circuits'.
An alternative system known as "two's complement" is a better system for this.
Two's Complement
21
As defined by the Microsoft Press, 'Computer Dictionary', 2nd Ed., 'Complement' means:
'Loosely, a number that can be thought of as the "mirror image" of another number written to the
same base, such as base 10 or base 2. Complements are commonly used to represent negative
numbers. Two types of complements are encountered in computer-related contexts:
0 then the rest of the seven bits represent normal binary numbers, i.e. 0 to 127 are
possible;
1 then this represents -128 which is to be added to the total of the other seven bits that
represent a normal binary number.
Still confused? Here are a few examples:
00000001 represents 1 (a positive number, i.e. the MSB is 0, and the other
seven bits totalling 1)
00000101 represents 5 (a positive number, i.e. the MSB is 0, and the other
seven bits totalling 5)
10000001 represents -127 (a negative number, i.e. the MSB is -128 to which
we add the total of other seven bits, i.e. 1, therefore -127)
10000101 represents -123 (a negative number, i.e. the MSB is -128 to which
we add the total of other seven bits, i.e. 5, therefore -123)
11011111 represents -33 (a negative number, i.e. the MSB is -128 to which we
add the total of other seven bits (64+16+8+4+2+1), i.e. 95, therefore
22
-33)
We need to be able to generate negative numbers in the two's complement binary number
system. This is achieved by first 'flipping' all of the binary digits within the corresponding
positive number such that all the 1s become 0's and 0's become 1's.
(This process is referred to as taking the one's complement). In order to create the two's
complement we simply add 1 to this result. For example the decimal number 13 can be
represented in two complement as: 00001101
if we wish to generate -13 we need to first take its one's complement i.e.:
11110010
and when we add 1 the two's component is discovered to be:
11110011
You should be able to see that this represents -13 (-128+64+32+16+0+0+2+1)
Once we have decided that we are working in two's complement representation and using eight
bit numbers then numbers such as 200 or -135 are out-of-range and not valid. If the
addition/subtraction of two binary number leads to number out of this range than an overflow
error is encounted. This error can be readily detected by comparing the carry -n and carry out bits
of the MSB (sign bit), but more of this later. It is worthwhile noting that in order to increase the
range of number that can be handled more bits can be used to store the number. For example if
we use 16 bits then numbers in the range -32768 (-1*216-1) to +32767 (216-1-1)]
23
The two's complement of 11 is 11110101
00010010 +
11110101
00000111 (with a carry of 1 which is ignored in this case)
00000111 is binary for 7 therefore we have what we wanted i.e. 18-11.
Example 1: 7-9 = ?
7 is represented as 00000111
9 is represented as 00001001
The one's complement of 9 is 11110110
The two's complement of 9 is 11110111
In example 1 we intentionally ignored the carry bit, however there are times when the presence
of a carry bit would signify an overflow and these need to be considered (e.g. 64+96). The ALU
of the CPU can detect an overflow condition by comparing the states of the carry in to and carry
out from, the sign bit.
The following two examples exemplify this comparison, the first has the same value in the carry-
in as the carry-out and therefore gives the correct result. However in the second case the values
in the carry-in and carry-out differ and therefore the results is incorrect.
24
To ensure that you understand two's complement for all of the following additions first convert
the decimal numbers to eight bit two's complement binary representation, add the numbers
together and check your results.
Example 1:
Question :
110 + 110 = ?
Answer:
000000012 +
000000012
________
000000102 = 210
Example 2:
Question :
110 - 110 = ?
Answer:
000000012 +
111111112 (i.e. the two's complement of 000000012)
________
000000002 = 010 (Note: the carry into and out of the MSB (i.e. sign bit) is 1 therefore this is a
valid answer)
Example 2:
Question :
-110 - 210 = ?
Answer:
111111112 + (i.e. the two's complement of 000000012)
111111102 (i.e. the two's complement of 000000102 i.e. 210)
25
________
111111012 = -310 (Note: the carry into and out of the MSB is 1 therefore this is a valid answer)
Questions
1) 410 + 310 = ?
2) 310 - 410 = ?
3) -410 - 310 = ?
4) 1310 + -1710 = ?
5) 9610 + 3210 = ? (Note something 'special' occurs here!)
Further Exercises
What is the (8 bit) two's complement representation of:
1) 110
2) 1010
3) 6710
4) 12710
5) -110
6) -6610
7) -12810
Real Numbers
Thus far we have seen how bits stored in a computer can be used to represent unsigned integers
using the binary number system and with a slight modification signed integers can also be
represented. Additionally, by using more and more bits larger (absolute) numbers can be
represented. However, what about numbers such as 1.5 or 657.674, i.e. real numbers, how can
we represent these.
26
2.floating point representation.
Fixed-point Representation
As we have seen above binary numbers could have the equivalent of a decimal point, a so-call
binary point, which can separate the integer part of the number from the fractional part. For
example the real binary number 101.11 would represent
4+0+1+1/2+1/4 or 5.75.
Note 1: The more bits bit used to assign the integer part increases the range of integers that may
be represented while increasing the number of bits representing to fractional component
increases the precision to which a number (e.g. an approximation of Pi) could be represented.
Note 2: Within fixed-point binary numbers moving the binary point to the left one position has
the effect of dividing the number by two and moving it to the right multiples the number by two
(c.f. with the decimal system in which a move left divides by 10 and right multiples by 10).
However, how is the position of the binary point indicated, i.e. how can the number 101.11 be
distinguished from 10.111?
The answer to this is that it is up to the programmer to decide and ensure that his code treats the
integer part differently from the fractional part. For example a programmer could decide that a
number should be represented by 16 bits i.e. 2 bytes. The first byte representing the integer part
and the second representing the fractional part. These latter eight bits would give the number the
precision of 1 in 256 (enough to represent cents if the programmer was concerned with money).
Note: In modern languages such a C, C++, Visual BASIC there is no fixed-point number types
already defined by the language. (Although the 'date' and 'currency' number types defined in
Visual BASIC is related to fixed-point representations.)
Floating-point Numbers
A floating-point number is similar to scientific notation, in which a number is expressed in two
parts. The first is called the mantissa and the other the exponent. For example the number:
1903810 can be written as 1.9038x104
In this case the mantissa is 1.9038 and the exponent is 4
Here is another example:
0.0032510 can be written as 3.25x10-3
Here the mantissa is 3.25 and the exponent -3.
We could use the same system in binary however a slightly different system is usually employed
in floating-point binary numbers.
27
In this case all of the mantissa appears to the right of the decimal point. For example:
1101.00112 becomes 0.110100112 x 24; and
0.0001012 becomes 0.1012x2-3
Here is an example:
28
0 0000 0 (= 1/2) 1
Further Question
If four bytes were used to represent a floating point number and employed the above system
what would be the smallest, greatest, and smallest positive fraction that could be handled by this
system? (NB: Often floating-point numbers stored in four bytes are referred to as single precision
reals where as if eight are used then these are known as double precision reals.)
Partial Answer
Assuming that the mantissa is stored in the first three bytes and the final bytes stores the
exponent and both are in two's complement format then:
The largest single precision number would be:
01111111 11111111 11111111 01111111
ASCII
29
Thus far in the course we have only considered how integers (both unsigned and signed) as well
as real number are represented and therefore stored in memory. What about letters, words,
sentences, etc. (often referred to as strings)
The answer is to develop a system in which each character is given a number code. For example
the letter 'A' could be coded as the number 1 and 'b' as 2, etc. Once such a system has been set up
the codes developed would encompass a 'character set'.
The most common character set in use today in a wide range of computer systems is ASCII.
(Note in ASCII 'A' is not represented by the number 1 it is given the number 65).
According to Microsoft Press Computer dictionary ASCII is an acronym standing for:
American Standard Code for Information Interchange. A coding scheme using 7 or 8 bits that
assigns numeric values to up to 256 characters, including letters, numerals, punctuation marks,
control characters, and other symbols. ASCII was developed in 1968 to standardize data
transmission among disparate hardware and software
systems and is built into most minicomputers and all personal computers.
ASCII Equivalents: 'A' Through 'Z'
65 A 66 B 67 C
68 D 69 E 70 F
71 G 72 H 73 I
74 J 75 K 76 L
77 M 78 N 79 O
80 P 81 Q 82 R
83 S 84 T 85 U
86 V 87 W 88 X
89 Y 90 Z
30
49 1
50 2
51 3
52 4
53 5
54 6
55 7
56 8
57 9
ASCII is not the only coding system that has been devised to represent characters however it is
widely used. It has one major drawback in that it only uses 256 character codes, not enough to
store all of the characters in all of the known languages, as well as common symbols. In order to
store all of these a greater range of numbers must be used. Unicode has been defined for this
purpose:
Unicode
Unicode is a character-encoding scheme that uses 2 bytes for every character. The International
Standards Organization (ISO) defines a number in the range of 0 to 65,535 (216 – 1) for just
about every character and symbol in every language (plus some empty spaces for future growth).
On all 32-bit versions of Windows, Unicode is used by the Component Object Model (COM),
the basis for OLE and ActiveX technologies. Unicode is fully supported by Windows NT.
Although both Unicode and DBCS have double-byte characters, the encoding schemes are
completely different.
Within Microsoft's common operating systems and products the following character sets are
used:
31
As you can see from the above tables of ASCII values both letters and numbers can be
represented by a single byte. As such, it is possible to store the number 1.234 as a string of 5
characters or in the floating-point representation discussed above. The former has the advantage
that it can be readily transferred between computers however as its a string of characters doing
arithmetic on it is not really possible.
32
BASIC NETWORK CONCEPTS
Networks are an interconnection of computers. These computers can be linked together using a
wide variety of different cabling types, and for a wide variety of different purposes.
The basis reasons why computers are networked are
It would not be necessary for users to transfer files via electronic mail or floppy disk, rather, each
user could access all the information they require, thus leading to less wasted time and hence
greater productivity.
Imagine the benefits of a user being able to directly fax the Word document they are working on,
rather than print it out, then feed it into the fax machine, dial the number etc.
Small networks are often called Local Area Networks [LAN]. A LAN is a network allowing easy
access to other computers or peripherals. The typical characteristics of a LAN are,
33
hardware makes network connections simple and quick.
On power-up, the computer detects the new network card, assigns the correct resources to it, and
then installs the networking software required for connection to the network. All the user need do
is assign the network details like computer name.
For Ethernet or 10BaseT cards, each card is identified by a twelve digit hexadecimal number.
This number uniquely identifies the computer. These network card numbers are used in the
Medium Access [MAC] Layer to identify the destination for the data. When talking to another
computer, the data you send to that computer is prefixed with the number of the card you are
sending the data to.
This allows intermediate devices in the network to decide in which direction the data should go,
in order to transport the data to its correct destination.
initialization routine
34
interrupt service routine releases processor to continue previous work
if the computer hangs, remove one board at a time until the problem disappears
define a generic voice and data wiring system that is multi-purpose and multi-vendor
horizontal wiring
backbone wiring
Horizontal Wiring
The horizontal wiring extends from the wall outlet to the system center (telecommunications
closet). It includes the
standardized media, Outlet A=4pair 100ohm UTP, Outlet B=same or 2 pair 150ohm STP
36
Backbone Wiring The backbone wiring system interconnects telecommunication closets,
equipment rooms and entrance facilities (i.e., the outside world). Some general features are
star topology
interconnections between any two TC must not go through more than 3 cross connects
Cabling
Cable is used to interconnect computers and network components together. There are THREE
main cable types used today [twisted pair, coax and fiber optic]. The choice of cable depends
upon a number of factors, like
cost
distance
speed
reasonably cheap
reasonably easy to terminate [special crimp connector tools are necessary for reliable
operation
37
UTP is prone to interference, which limits speed and distances
Category 5 cable uses 8 wires. The various jack connectors used in the wiring closet look like,
The patch cord which connects the workstation to the wall jack looks like,
Distance limitations exist when cabling. For category 5 cabling at 100Mbps, the limitations
effectively limit a workstation to wall outlet of 3 meters, and wall outlet to wiring closet of 90
meters.
All workstations are wired back to a central wiring closet, where they are then patched
accordingly. Within an organization, the IT department either performs this work or sub-
contracts it to a third party.
38
In 10BaseT, each PC is wired back to a central hub using its own cable. There are limits imposed
on the length of drop cable from the PC network card to the wall outlet, the length of the
horizontal wiring, and from the wall outlet to the wiring closet.
Patch Cables
Patch cables come in two varieties, straight through or reversed. One application of patch cables
is for patching between modular patch panels in system centers. These are the straight through
variety. Another application is to connect workstation equipment to the wall jack, and these
could be either straight through or reversed depending upon the manufacturer. Reversed cables
are normally used for voice systems.
If the colors are in the same order on both plugs, the cable is straight through. If the colors
appear in the reverse order, the cable is reversed.
Coaxial Cable
Coaxial cable has traditionally been the cable of choice for low cost, small user networks. This
has been mainly due to its ease of use and low cost. Persons with mininal network understanding
can readily build a LAN using coax components, which can often be purchased in kit ready
format.
The general features of coaxial cable are,
medium capacity
10Base5 uses a thicker solid core coaxial cable (also called Thick-Net)
39
Thin coaxial cable [RG-58AU rated at 50 ohms], as used in Ethernet LAN's, looks like
The connectors used in thin-net Ethernet LAN's are T connectors (used to join cables together
and attach to workstations) and terminators (one at each end of the cable). The T-connectors and
terminators look like
Fiber Optic
Fiber optic cable is considered the default choice for connections involving high speed [large
bandwidth requirements like video, large database systems], long distances and interconnecting
networks. It costs more than either twisted pair or coax, and requires special connectors and
jointing methods.
The features of fiber-optic cable systems are,
expensive
low loss
difficult to join
long distance
Fiber optic is often used to overcome distance limitations. It can be used to join two hubs
together, which normally could not be connected due to distance limitations. In this instance, a
UTP to Fiber transceiver [often referred to as a FOT] is necessary.
NETWORK SEGMENTS
A network segment
is a length of cable
40
devices can be attached to the cable
has a limit on its length and the number of devices which can be attached to it
Large networks are made by combining several individual network segments together, using
appropriate devices like routers and/or bridges.
In the above diagram, a bridge is used to allow traffic from one network segment to the other.
Each network segment is considered unique and has its own limits of distance and the number of
connections possible.
When network segments are combined into a single large network, paths exist between the
individual network segments. These paths are called routes, and devices like routers and bridges
keep tables which define how to get to a particular computer on the network. When a packet
arrives, the router/bridge will look at the destination address of the packet, and determine which
network segment the packet is to be transmitted on in order to get to its destination.
41
In the above diagram, a packet arrives whose destination is segment B. The bridge forwards this
incoming packet from segment A to the B segment.
REPEATERS
Repeaters EXTEND network segments. They amplify the incoming signal received from one
segment and send it on to all other attached segments. This allows the distance limitations of
network cabling to be extended. There are limits on the number of repeaters which can be used.
The repeater counts as a single node in the maximum node count associated with the Ethernet
standard [30 for thin coax].
Repeaters also allow isolation of segments in the event of failures or fault conditions.
Disconnecting one side of a repeater effectively isolates the associated segments from the
network.
Using repeaters simply allows you to extend your network distance limitations. It does not give
you any more bandwidth or allow you to transmit data faster.
42
It should be noted that in the above diagram, the network number assigned to the main network
segment and the network number assigned to the other side of the repeater are the same. In
addition, the traffic generated on one segment is propagated onto the other segment. This causes
a rise in the total amount of traffic, so if the network segments are already heavily loaded, it's not
a good idea to use a repeater.
Summary of Repeater features
BRIDGES
Bridges interconnect Ethernet segments..
The advantages of bridges are
since bridges buffer frames, it is possible to interconnect different segments which use
different MAC protocols
since bridges work at the MAC layer, they are transparent to higher level protocols
by subdividing the LAN into smaller segments, overall reliability is increased and the
network becomes easier to maintain
help localize network traffic by only forwarding data onto other segments as required
(unlike repeaters)
The disadvantages of bridges are
in complex networks, data may be sent over redundant paths, and the shortest path is not
always taken
43
Bridges are ideally used in environments where there a number of well defined workgroups, each
operating more or less independent of each other, with occasional access to servers outside of
their localized workgroup or network segment. Bridges do not offer performance improvements
when used in diverse or scattered workgroups, where the majority of access occurs outside of the
local segment.
The diagram below shows two separate network segments connected via a bridge. Note that each
segment must have a unique network address number in order for the bridge to be able to
forward packets from one segment to the other.
Ideally, if workstations on network segment A needed access to a server, the best place to locate
that server is on the same segment as the workstations, as this minimizes traffic on the other
segment, and avoids the delay incurred by the bridge.
Summary of Bridge features
fault tolerant by isolating fault segments and reconfiguring paths in the event of failure
redundant paths to other networks are not used (would be useful if the major path being
used was overloaded)
ROUTERS
44
Packets are only passed to the network segment they are destined for. They work similar to
bridges and switches in that they filter out unnecessary network traffic and remove it from
network segments. Routers generally work at the protocol level.
Routers were devised in order to separate networks logically. For instance, a TCP/IP router can
segment the network based on groups of TCP/IP addresses. Filtering at this level (on TCP/IP
addresses, also known as level 3 switching) will take longer than that of a bridge or switch which
only looks at the MAC layer.
Typically, an organization which connects to the Internet will install a router as the main
gateway link between their network and the outside world. By configuring the router with access
lists (which define what protocols and what hosts have access) this enforces security by restricted
(or allowing) access to either internal or external hosts.
For example, an internal WWW server can be allowed IP access from external networks, but
other company servers which contain sensitive data can be protected, so that external hosts
outside the company are prevented access (you could even deny internal workstations access if
required).
provides security
HUBS
There are many types of hubs. Passive hubs are simple splitters or combiners that group
workstations into a single segment, whereas active hubs include a repeater function and are thus
capable of supporting many more connections.
45
Nowadays, with the advent of 10BaseT, hub concentrators are being very popular. These are
very sophisticated and offer significant features which make them radically different from the
older hubs which were available during the 1980's.
These 10BaseT hubs provide each client with exclusive access to the full bandwidth, unlike bus
networks where the bandwidth is shared. Each workstation plugs into a separate port, which runs
at 10Mbps and is for the exclusive use of that workstation, thus there is no contention to worry
about like in Ethernet.
These 10BaseT hubs also include buffering of packets and filtering, so that unwanted packets (or
packets which contain errors) are discarded. SNMP management is also a common feature.
Ports can also be buffered, to allow packets to be held in case the hub or port is busy. And,
because each workstation has it's own port, it does not contend with other workstations for
access, having the entire bandwidth available for it's exclusive use.
The ports on a hub all appear as one Ethernet segment. In addition, hubs can be stacked or
cascaded (using master/slave configurations) together, to add more ports per segment. As hubs
do not count as repeaters, this is a better option for adding more workstations than the use of a
repeater.
Hub options also include an SNMP (Simple Network Management Protocol) agent. This allows
the use of network management software to remotely administer and configure the hub. Detailed
statistics related to port usage and bandwidth are often available, allowing informed decisions to
be made concerning the state of the network.
In summary, the advantages for these newer 10BaseT hubs are,
NETWORK TOPOLOGY
Topology refers to the way in which the network of computers is connected. Each topology is
suited to specific tasks and has its own advantages and disadvantages.
The choice of topology is dependent upon
cost
There are FOUR major competing topologies
Bus
Ring
Star
FDDI
Most networking software support all topologies.
Bus Topology
all workstations connect to the same cable segment
two wire, generally implemented using coaxial cable during the 1980's
The bus cable carries the transmitted message along the cable. As the message arrives at each
workstation, the workstation computer checks the destination address contained in the message
to see if it matches it's own. If the address does not match, the workstation does nothing more.
If the workstation address matches that contained in the message, the workstation processes the
47
message. The message is transmitted along the cable and is visible to all computers connected to
that cable.
There are THREE common wiring implementations for bus networks
10Base2 (thin-net, CheaperNet) 50-ohm cable using BNC T connectors, cards provide
transceiver
10Base5 (ThickNet) 50-ohm cable using 15-pin AUI D-type connectors and external
transceivers
10BaseT (UTP) UTP cable using RJ45 connectors and a wiring centre
The above diagram shows a number of computers connected to a Bus cable, in this case,
implemented as Thin Ethernet. Each computer has a network card installed, which directly
attaches to the network bus cable via a T-Connector.
It is becoming common to use 10BaseT (UTP) for implementing Ethernet LANS. Each
workstation is wired in star fashion back to a concentrator wiring centre (hub). The hub is a
multi-port device supporting up to about 32 ports. One of these ports is connected to a server, or
the output of the hub can be connected to other hubs.
Ethernet 802.3: Carrier Sense Multiple Access with Collision Detection (CSMA/CD)
This protocol is commonly used in bus (Ethernet) implementations.
48
Multiple access refers to the fact that in bus systems, each station has access to the common
cable.
Carrier sense refers to the fact that each station listens to see if no other station is transmitting
before sending data.
Collision detection refers to the principle of listening to see if other stations are transmitting
whilst we are transmitting.
In bus systems, all stations have access to the same cable medium. It is therefore possible that a
station may already be transmitting when another station wants to transmit.
Rule 1 is that a station must listen to determine if another station is transmitting before initiating
a transmission. If the network is busy, then the station must back off and wait a random interval
before trying again.
Rule 2 is that a station which is transmitting must monitor the network to see if another station
has begun transmission. This is a collision, and if this occurs, both stations must back off and
retry after a random time interval. As it takes a finite time for signals to travel down the cable, it
is possible for more than one station to think that the network is free and both grab it at the same
time.
CSMA/CD models what happens in the real world. People involved in group conversation tend
to obey much the same behavior.
49
RG58-AU 50-ohm cable, 0.2"
Transceivers 802.3
50
As the number of workstations increase, the speed of the network slows down
Ring Topology
workstations connect to the ring
51
Wiring is performed in a physical star fashion, with cables wired directly from each workstation
back to the MAU.
52
Either
53
Or
maximum patch cable distance between an 8228 MAU and a station (not including 8'
adapter cable) = 150 feet (45 meters)
maximum patch cable distance between two 8228's = 150 feet (45 meters)
maximum patch cable connecting all 8228's = 400 feet (120 meters)
Rules
54
stations are connected into the jacks of the 8228 units
Advantages Disadvantages
Star Topology
all wiring is done from a central point (the server or hub)
has the greatest cable lengths of any topology (and thus uses the most amount of cable)
55
Star Topology: Summary
Advantages Disadvantages
FDDI Topology
100mbps
56
Fiber Distributed Data Interface
FDDI is based on two counter rotating 100-Mbit/sec token-passing rings. The rings consist of
point to point wiring between nodes which repeat the data as it is received.
The primary ring is used for data transmission; the secondary is used for data transmission or to
back up the primary ring in the event of a link or station failure. FDDI supports a sustained
transfer rate of about 80Mbps, a maximum of 1000 connections (500 nodes) and a total distance
of 200 kilometers end to end. There is a maximum distance of 2 kilometers between active
nodes.
57
58