CSE 203G: Introduction To C: Lecture - 2
CSE 203G: Introduction To C: Lecture - 2
Lecture – 2
CPU
Hard disk
Memory
Computer
Computer
• Computers (CPUs) utilise programs for data processing
• For this, it relies on two major components:
• Memory – Stores programs and data. Gets destroyed when the computer is
powered off
• Hard disk – stores programs/data permanently
Computer
Computer
1.2. Notice that the individual bits are numbered, beginning with 0 (for the rightmost bit) and extending to 7from 4 to 16
referred to as 1K. Modem small computers have memories whose sizes typically range
6 5 4 have 3 memories
2 1 0 that are organized into rather than bytes. Each word will consist
words
3,….255) 16,777,216 characters and/or instructions can be stored in the computer’s memory. If the entire memory is used to (typically
The use a 32- or a 36-bit word permits one numeric quantity, or a small of characters
group 4
or to be represented within a single word of memory. Large computers commonly have several million
5),
represent character data (which is actually words
quite (Le.,
unlikely),
several then over 200,000
megawords) names and addresses can be stored within the
of memory.
computer at any one time, assuming 80 characters for each name and address.
• 1 word = 4 bytes, 1If KB (Kilo
the memory Bytes)
is used to represent= 1024
numeric bytes
data rather than names = and210addresses,
Bytes then more than 4 million individual
numbers can be stored at any one time, assuming each numeric quantity requires 4 bytes of memory.
• 1 MB (Mega Bytes) = 1024 (210) KB = 220 bytes, 1 GB (Giga Bytes) = 1024 MB
Large computers have memories that are organized into words rather than bytes. Each word will consist
of a relatively large number of bits-typically 32 or 36. The bit-wise organization of a 32-bit word is
illustrated in Fig. 1.3. Notice that the bits are numbered, beginning with 0 (for the rightmost bit) and extending
to 3 1 (the leftmost bit).
Memory
• CPUs are extremely fast
• To match its speed for faster processing, we must supply data at the
same speed if possible
• Remember, data is stored permanently in the hard disk
• Unfortunately, hard disks are quite slow
• Memory acts as an intermediary between the hard disk and the CPU
• The most common memory is RAM (Random Access Memory)
• Memory is much faster than hard disks, but still slower than the CPU
Memory
• The more memory your computer has, the more data it can store to
supply this data to the CPU
• You might ask, why not we have as much memory as hard disks?
• Hard disks are cheaper but memory is quite expensive!
• So we need to find a balance!
Memory
• Memory is
divided into
locations
• Each location has
a unique address
• Inside each
location we store
certain amount of
data, represented
with bits or its
other multiples
Computer: speed and reliability
• Because of its extremely high speed, a computer can carry out
calculations within minutes that might require many days, perhaps
even months or years, if carried out by hand
• The time required to carry out simple computational tasks, such as
adding two numbers, is usually expressed in terms of microseconds (1
µsec = 10-6 sec) or nanoseconds (1 nsec = 10-3 µsec = 10-9 sec)
• Thus, if a computer can add two numbers in 10 nanoseconds (typical
of a modern medium-speed computer), 100million (108) additions will
be carried out in one second
Computer: speed and reliability
• Computers are also extremely reliable
• They do not make mistakes
• The mistakes you see or reported on the news are due to
programming errors or data entry errors
• Mostly by human errors!
Modes of operations
• Two different modes:
• Batch mode and the interactive mode
• Each has its own advantages for certain types of problems
• In batch processing, a number of jobs (programs) are entered into the
computer, stored internally, and then processed sequentially, one by
one
• Examples:
• Programs to add two numbers by John
• Programs to subtract two numbers by Alice
• Programs to multiply two numbers by Bob
• John’s job -> Alice’s job -> Bob’s job
Batch processing
• Jobs are submitted to an operator
• Operator groups jobs based on a similarity
• Submit grouped jobs in batches
• This mode of operation is well-suited to jobs that require large
amounts of computer time or are physically lengthy
• However, a small job can be scheduled in a long queue waiting for its
turn!
Timesharing & Interactive processing
• Timesharing allows many different users to use a single computer
simultaneously
• Timesharing is best suited for processing relatively simple jobs that do
not require extensive data transmission or large amounts of computer
time
•
again appears, and the entire procedure is repeated. If the student types no, the mess
Goodbye
Notice the manner in which the student and the computer appear to be conve
the student waits until he or she sees the calculated value of the area before decidi
calculation. If another calculation is initiated, the new value for the radius suppl
previously calculated results.