1. Amity School of Engineering & Technology
1
Amity School of Engineering & Technology
Programming for Problem Solving (CSE 104)
Credit Units: 03
Mr. VIVEK PARASHAR
Assistant Professor CSE
2. Amity School of Engineering & Technology
2
Schools ASET
Program & Semester CSE I semester
Course Title Programming for Problem Solving
Course Code CSE 104
Credit Unit 03
Faculty Name
Mr. Vivek Parashar
Email Vparahsar@gwa.amity.edu
Contact no. +918878644486
3. Amity School of Engineering & Technology
3
About Myself
• I am Vivek Parashar Assistant Professor (ASET)
• B.Tech (2002) and M.Tech (2006) from NIT Raipur
• Having more than 17 years of Teaching and
Training experience
• I was a corporate trainer at Wipro Technologies.
4. Amity School of Engineering & Technology
My Promise to you
• I will treat you with respect
• I will be available for questions (after class, during
office hours)
• I will arrive prepared to teach
• I will try to be engaging and helpful
• I will grade you fairly and objectively
4
5. Amity School of Engineering & Technology
University Expectations
• Come to class on-time (especially during exams)
• Turn in work on-time
• Do all work independently (except group work)
• Follow Rules of Conduct and Academic Behavior
Standards as detailed in the Student Regulations.
• Take responsibility for your own learning!
5
6. Amity School of Engineering & Technology
My Expectations
• Treat each other with respect
• Work hard
• Keep silence in class room
• Ask if you have questions!
6
7. Amity School of Engineering & Technology
Course Objectives
• The objective of this course is to acquaint the students with the
basics of computers system, its components.
• To make the student learn a programming language.
• To learn problem solving techniques.
• To teach the student to write programs in C and to solve the
problems.
8. Amity School of Engineering & Technology
Learning Outcomes
• After Completion of this course the student would be able to
• Read, understand and trace the execution of programs written in C
language.
• Write the C code for a given algorithm.
• Implement Programs with pointers and arrays, perform pointer
arithmetic, and use the pre-processor.
• Write programs that perform operations using derived data types.
9. Amity School of Engineering & Technology
Syllabus
Module 1: Introduction to Programming:
Introduction to components of a computer system (disks, memory,
processor, where a program is stored and executed, operating system,
compilers etc.) Idea of Algorithm: steps to solve logical and numerical
problems. Representation of Algorithm: Flowchart/ Pseudocode with
examples. From algorithms to programs; source code, variables (with
data types) variables and memory locations, Syntax and Logical Errors
in compilation, object and executable code.
10. Amity School of Engineering & Technology
Module 2: Programming Essential:
Arithmetic expressions and precedence, Conditional Branching and
Loop, Writing and evaluation of conditionals and consequent branching
, Iteration and loops.
Module 3: Arrays:
Arrays (1-D, 2-D), Character arrays and Strings.
Module 4: Basic Algorithms:
Searching, Basic Sorting Algorithms (Bubble, Insertion and
Selection), Finding roots of equations, notion of order of complexity
through example programs (no formal definition required)C
11. Amity School of Engineering & Technology
Module 5: Function:
Functions (including using built in libraries), Parameter passing in
functions, call by value, Passing arrays to functions: idea of call by
reference
Module 6: Recursion:
Recursion, as a different way of solving problems. Example programs,
such as Finding Factorial, Fibonacci series, Ackerman function etc.
Quick sort or Merge sort.
Module 7: Structure:
Structures, Defining structures and Array of Structures.
12. Amity School of Engineering & Technology
Module8: Pointers:
Idea of pointers, Defining pointers, Use of Pointers in self-referential
structures, notion of linked list (no implementation)
Module 9: File handling:
Basics of file Handling.
13. Amity School of Engineering & Technology
Text & References: Books
• Let us C by Yashavant Kanetkar
• The complete reference by Herbert Schild
• Programming in ANSI C by E. Balaguruswamy
• Head first C by David Griffiths
• C-How to Program by Paul and Harvey Deitel
14. Amity School of Engineering & Technology
The word computer comes from the word
“compute”, which means, “to calculate” may
came from Latin word” computator”
What is a Computer?
A computer is an electronic device that accepts data
from the user, processes it, produces results, displays
them to the users, and stores the results for future
usage
Computer
15. Amity School of Engineering & Technology
Data Processing
The activity of processing data using a computer is called
data processing
Data
Capture Data
Manipulate Data
Output Results
Information
Data is raw material used as input and information
is processed data obtained as output of data
processing
17. Amity School of Engineering & Technology
The characteristics of the computer system are
as follows −
18. Amity School of Engineering & Technology
Speed
• A computer works with much higher speed and accuracy
compared to humans while performing mathematical
calculations. Computers can process millions (1,000,000) of
instructions per second. The time taken by computers for their
operations is microseconds and nanoseconds.
Accuracy
• Computers perform calculations with 100% accuracy. Errors
may occur due to data inconsistency or inaccuracy.
Diligence
• A computer can perform millions of tasks or calculations with
the same consistency and accuracy. It doesn’t feel any fatigue
or lack of concentration. Its memory also makes it superior to
that of human beings.
19. Amity School of Engineering & Technology
Versatility
• Versatility refers to the capability of a computer to perform
different kinds of works with same accuracy and efficiency.
Reliability
• A computer is reliable as it gives consistent result for similar
set of data i.e., if we give same set of input any number of
times, we will get the same result.
Automation
• Computer performs all the tasks automatically i.e. it performs
tasks without manual intervention.
Memory
• A computer has built-in memory called primary memory where
it stores data. Secondary storage are removable devices such
as CDs, pen drives, etc., which are also used to store data.
20. Amity School of Engineering & Technology
(Continued from previous slide..)
No I.Q.
• A computer does only what it is programmed to do. It
cannot take its own decision in this regard
No Feelings
• Computers are devoid of emotions. Their judgement is
based on the instructions given to them in the form of
programs that are written by us (human beings)
(Continued on next slide)
21. Amity School of Engineering & Technology
• At around 600 BC ABACUS was invented which was qualified
as Digital Computer
22. Amity School of Engineering & Technology
Evolution of Computers
Blaise Pascal invented the first mechanical adding
machine” Pascaline” in 1642-44
23. Amity School of Engineering & Technology
Baron Gottfried Wilhelm von Leibniz
invented the first calculator for
multiplication in 1671
24. Amity School of Engineering & Technology
• The first writing devices were
designed as early as the 1700s
and the first to be patented was
by Henry Mill in London England
in 1714. the first practical
typewriter and the word "Type-
Writer" was first developed and
patented in 1868 by Christopher
Sholes and is considered to be
the first typewriter. Also, the
Type-Writer introduced
the QWERTY layout, which is
still used on almost all US
keyboards today
25. Amity School of Engineering & Technology
• During the late 1700s, Joseph Marie Jacquard developed
the Jacquard Loom that was later expanded upon in the late
1800s and early 1900s by Herman Hollerith with his keypunch
inventions.
Jacquard Loom
Herman Hollerith punchcards
26. Amity School of Engineering & Technology
• Charles Babbage is
considered to be
the father of modern
digital computers
• He designed “Difference
Engine” in 1833
• He designed a fully automatic
analytical engine in 1842 for
performing basic arithmetic
functions which was completed
in 1910 after his death in 1871.
• His efforts established a
number of principles that are
fundamental to the design of
any digital computer
27. Amity School of Engineering & Technology
Some Well Known Early Computers
The Mark I Computer (1937-44)
• Known as Automatic
Sequence Controlled
Calculator
• Fully automatic calculating
machine designed by
Howard A Aiken in
collaboration with IBM
• Design was based on
punched card machinery.
• It was complex in design
and huge in size.
• Uses 3000 electrically
actuated switches and was
50 ft long and 8 ft hig
28. Amity School of Engineering & Technology
The Attanasoff-Berry Computer (1939-42)
• This electronic machine was developed by Dr. John attanasoff
to solve mathematical equations.
• It used 45 vacuum tubes for internal logic and capacitors
storage
29. Amity School of Engineering & Technology
The EDVAC
• The Electronic Discrete Variable Automatic Computer was designed J. Presper Eckert and
John Mauchly at the University of Pennsylvania on the concept of stored program concept(
in which the data and instructions are stored inside the memory).Stored program concept
was given by Von Neumann which introduced the idea of storing both instructions as well
data in the binary form instead of decimal numbers
30. Amity School of Engineering & Technology
The EDSAC ( 1947 – 49)
• Britishers developed the Electronic Delay Storage automatic Calculator.In
this machine addition operations was accomplished in 1500 microseconds
and multiplication in 4000 microsecond
31. Amity School of Engineering & Technology
Manchester Mark-I(1948)
• This computer was a small experimental machine based in the stored
program concept
• Designed by scientists headed by M.H.A Newman
• Its storage capacity was 32 words and each of 31binary digits
32. Amity School of Engineering & Technology
UNIVAC I (1951)
• Universal Automatic Computer was the first digital computer. Many UNIVAC machines were
produced but first business use computer , a UNIVAC I was used by General Electric
Corporation in 1954In 1952 IBM introduced the 701 commercial computer. In rapid
succession, improved models of the univac-I and other 70 series machines were introduced
33. Amity School of Engineering & Technology
The first hard disk drive,
made by IBM on 14 sept
1956. It was called
the IBM Model 350 Disk.
It had 50 24-inch
disks . This hulk of a
storage unit could store
a whopping 5MB of
data. It could hold 3.75
Megabytes. And cost
$10,000 per megabyte
and a lease of $3,200
per month. The weight
was 250 KG
34. Amity School of Engineering & Technology
On September 9, 1947, the
world's first computer bug was
recorded. But this was no
ordinary 'software bug'. It was a
real-life moth that was causing
the issues with
the computer's hardware. This
“first actual case of bug being
found" was recorded
by computer scientist Grace
Hopper.
35. Amity School of Engineering & Technology
Ten Interesting Facts about computers
1. The first electronic computer ENIAC weighed more than 27 tons and took up 1800 square
feet.
2. TYPEWRITER is the longest word that you can write using the letters only on one row of
the keyboard of your computer.
3. Doug Engelbart invented the first computer mouse in around 1964 which was made of
wood.
4. Therearemorethan 5000 new computer viruses released every month.
5. If there was a computer as powerful as the human brain, it would be able to do 38
thousand trillion operations persecond andhold morethan 3580 terabytes of memory.
36. Amity School of Engineering & Technology
• C Language was not called C at the beginning. It has been
named as C after passing many stages of evolution. Evolution
of C:
• ALGO -> BCPL -> B -> Tradition C -> K&R C -> ANSI C ->
ANSI/ISO C -> C99.
• It was developed at Bell Laboratories in 1972 by Dennis
Ritchie.
• Why it is named as C ? There is no such logic behind the
naming of C Language.
• It was developed to cover all the inabilities of B language
(simplified version of BCPL). So, it was just named C as it is
next to B in the English alphabets.
37. Amity School of Engineering & Technology
• C is the only programming language that exists for such a long
period and still it is widely used.
• C is the basis of many other programming languages like C++,
Java, JavaScript, Go, C#, PHP, Python, Perl, C-shell and
many more.
• Unix was one of the first operating system kernels
implemented in a language other than assembly and that was
C.
• Previously, C was considered as the high level language but
today many programmers consider it as a low level language
as it supports only scalar operations.
• C18 is the latest version of C programming Language
published in June 2018.
38. Amity School of Engineering & Technology
1. The password for the computer controls of nuclear tipped missiles of the U.S was
00000000 for eight years.
2. HP, Microsoft and Apple have one very interesting thing in common – they were all started
in a garage.
3. The first 1GB hard disk drive was announced in 1980 which weighed about 550 pounds,
and hada price tag of $40,000.
4. Theoriginal name of windows was Interface Manager.
5. The first microprocessorcreated by Intel was the 4004. It was designed for a calculator, and
in that time nobody imagined whereit would lead.
39. Amity School of Engineering & Technology
“Generation” in computer talk is a step in technology. It
provides a framework for the growth of computer
industry
Originally it was used to distinguish between various
hardware technologies, but now it has been extended
to include both hardware and software
Till today, there are five computer generations
Computer Generations
(Continued on next slide)
40. Amity School of Engineering & Technology
Generation
(Period)
Key hardware
technologies
Key software
technologies
Key characteristics
Some
representative
systems
First
(1942-1955)
Vacuum tubes
Electromagnetic
relay memory
Punched cards
secondary storage
Machine and
assembly
languages
Stored program
concept
Mostly scientific
applications
Bulky in size
Highly unreliable
Limited commercial
use and costly
Difficult commercial
production
Difficult to use
ENIAC
EDVAC
EDSAC
UNIVAC I
IBM 701
Second
(1955-1964)
Transistors
Magnetic cores
memory
Magnetic tapes
Disks for secondary
storage
Batch operating
system
High-level
programming
languages
Scientific and
commercial
applications
Faster, smaller, more
reliable and easier to
program than previous
generation systems
Commercial production
was still difficult and
costly
Honeywell 400
IBM 7030
CDC 1604
UNIVAC LARC
(Continued from previous slide..)
(Continued on next slide)
Computer Generations
41. Amity School of Engineering & Technology
Generation
(Period)
Key hardware
technologies
Key software
technologies
Key
characteristics
Some rep.
systems
Third
(1964-1975)
ICs with SSI and
MSI technologies
Larger magnetic
cores memory
Larger capacity
disks and
magnetic tapes
secondary storage
Minicomputers;
upward
compatible family
of computers
Timesharing
operating
system
Standardization
of high-level
programming
languages
Unbundling of
software from
hardware
Faster, smaller, more
reliable, easier and
cheaper to produce
Commercially, easier
to use, and easier to
upgrade than previous
generation systems
Scientific, commercial
and interactive on-
line applications
IBM 360/370
PDP-8
PDP-11
CDC 6600
(Continued from previous slide..)
(Continued on next slide)
Computer Generations
42. Amity School of Engineering & Technology
Generation
(Period)
Key hardware
Technologies
Key software
technologies
Key
characteristics
Some rep.
systems
Fourth (1975-
1989)
ICs with VLSI
technology
Microprocessors;
semiconductor memory
Larger capacity hard
disks as in-built
secondary storage
Magnetic tapes and
floppy disks as portable
storage media
Personal computers
Supercomputers based
on parallelvector
processing and
symmetric
multiprocessing
technologies
Spread of high-speed
computer networks
Operating systems for
PCs with GUI and
multiple windows on a
single terminal screen
Multiprocessing OS
with concurrent
programming
languages
UNIX operating system
with C programming
language
Object-oriented design
and programming
PC, Network-based,
and supercomputing
applications
Small, affordable,
reliable, and easy
to use PCs
More powerful
And reliable
mainframe
systems and
supercomputers
Totally general
purpose machines
Easier to produce
commercially
Easier to upgrade
Rapid software
development
possible
IBM PC and
its clones
Apple II
TRS-80
VAX 9000
CRAY-1
CRAY-2
CRAY-X/MP
(Continued from previous slide..)
(Continued on next slide)
Computer Generations
43. Amity School of Engineering & Technology
Generation
(Period)
Key hardware
technologies
Key software
technologies
Key
characteristics
Some rep.
systems
Fifth (1989-
Present)
ICs with ULSI
technology
Larger capacity
main memory, hard
disks with RAID
support
Optical disks as
portable read-only
storage media
Notebooks,
powerful desktop
PCs and
workstations
Powerful servers,
supercomputers
Internet
Cluster computing
Micro-kernel based,
multithreading,
distributed OS
Parallel
programming
libraries like MPI &
PVM
JAVA
World Wide Web
Multimedia, Internet
applications
More complex
supercomputing
applications
Portable computers
Powerful, cheaper,
reliable, and easier
to use desktop
machines
Powerful
supercomputers
High uptime due to
hot-pluggable
components
Totally general
purpose machines
Easier to produce
commercially, easier
to upgrade
Rapid software
development
possible
IBM notebooks
Pentium PCs
SUN Workstations
IBM SP/2
SGI Origin 2000
PARAM 10000
(Continued from previous slide..)
Computer Generations
44. Amity School of Engineering & Technology
(c) An IC Chip
(b) A Transistor
(a) A Vacuum Tube
Electronic Devices Used
in Computers of Different
Generations
45. Amity School of Engineering & Technology
Key Words/Phrases
Computer
Computer generations
Computer Supported Cooperative
Working (CSCW)
Data
Data processing
Data processor
First-generation computers
Fourth-generation computers
Garbage-in-garbage-out (GIGO)
Graphical User Interface (GUI)
Groupware
Information
Integrated Circuit (IC)
Large Scale Integration (VLSI)
Medium Scale Integration (MSI)
Microprocessor
Personal Computer (PC)
Second-generation computers
Small Scale Integration (SSI)
Stored program concept
Third-generation computers
Transistor
Ultra Large Scale Integration
(ULSI)
Vacuum tubes
46. Amity School of Engineering & Technology
• Intel has recently launched 10th-generation, 10-nanometer
silicon processor, codenamed “Ice Lake”
• According to Intel the chip has been designed with AI in mind.
There’s a new “dedicated instruction set” for support of neural
networks on the CPU and a dedicated engine for background
workloads.
• The second improvement is in the graphics capability. A new
graphic architecture offers double the performance of the
previous chip and shows the biggest leap in graphics
performance since the Skylake microarchitecture
launched back in 2015. Playing 1080p games and editing 4K
video should be faster, as should rendering content.
• Finally, the new chips will add support for the more efficient
and speedy Wi-Fi 6 standard.
47. Amity School of Engineering & Technology
• 11 variations of the chips, ranging from low-end Core i3's to
quad-core Core i7’s.
• Ryzen Pro 4000 series is the eight-core Ryzen 7 PRO 4750U,
which has a 1.7-gigahertz base frequency that can go all the
way up to 4.2GHz. It’s capable of running up to 16 threads at
once. AMD claims that the CPU provides more than twice the
performance of Intel Corp.’s comparable Core i7-10510U for
multithreaded use cases, such as when a worker is running a
complex professional application or has multiple programs
open. Single-thread performance is about the same.
• Advanced Micro Devices unveiled a new 7-nanometer, 16-
core Ryzen 3 processor and a 7-nanometer Navi graphics
processing unit (GPU) that will challenge Intel in chips for
gaming machines.
48. Amity School of Engineering & Technology
• The Ryzen 9 3950X has 16 cores, 32 threads, 4.7-GHz boost
frequency, 3.5 GHz base frequency, and 72 megabytes of
cache
• Apple is coming with new ‘A14’ chip will be manufactured
using TSMC’s(Taiwan Semiconductor Manufacturing
Company) new 5 nanometer production process, down from 7
nanometer fabrication seen in the A12 and A13.
• Apple has launched 12-core CPU with eight high-performance
“Firestorm” cores and at least four energy-efficient “Icestorm”
cores.
• Currently Apple has The A12Z chip used in iPad Pro has eight
cores: four high performance and four energy efficient.
50. Amity School of Engineering & Technology
What is Operating Systems ?
51. Amity School of Engineering & Technology
Operating system is an interface between user and the
computer hardware. The hardware of the computer cannot
understand the human readable language as it works on
binaries i.e. 0’s and 1’s. Also it is very tough for humans to
understand the binary language, in such case we need an
interface which can translate human language to hardware
and vice−versa for effective communication.
52. Amity School of Engineering & Technology
Types of Operating System:
There are Three Types of Operating Systems. They are:
•Single User − Single Tasking Operating System
•Single User − Multitasking Operating System
•Multi User − Multitasking Operating System
53. Amity School of Engineering & Technology
Single User – Single Tasking Operating System
In this type of operating system only one user can log into system and can perform
only one task at a time.
E.g: MS- DOS
Single User − Multitasking Operating System
This type of Operating System supports only one user to log into the system but a user
can perform multiple tasks at a time, browsing internet while playing songs etc.
E.g: Windows
Multi User − Multitasking Operating System
This type of Operating System provides multiple users to log into the system and also
each user can perform various tasks at a time. In a broader term multiple users can
logged in to system and share the resources of the system at the same time.
E.g: UNIX, LINUX etc.
55. Amity School of Engineering & Technology
Know your Computer first ?
Multi-core: means it's a single processor (CPU, Central
Processing Unit) with multiple cores. Each core = two
threads. A thread, in the simplest sense, is the most basic
level of code execution, so two threads can be seen as
two things that each core can work on simultaneously. So
an Oct-core CPU (8 cores) can work on 16 things at once.
Ex: Your friends working on same problem with you.
58. Amity School of Engineering & Technology
Now a days computers are equipped with L1,L2,L3 Cache
Memory. In multicore processors, each core may have
dedicated L1 and L2 cache, but they can share an L3
cache Level 3 (L3) cache is specialized memory
developed to improve the performance of L1 and L2. L1 or
L2 can be significantly faster than L3.
59. Amity School of Engineering & Technology
Generation of Computers: It depends on the size of
transistors. In every one or two years the generation
changes means the size of transistors placed on chip
changes. The size also play a great role, ex 10 nM,12 nM ,
Smaller the size faster the processor. 10nM means the
size of transistors.
i3 Core i3 processors first appeared in 2010 and are the
entry-level Intel chipsets with 2 cores (processors). Core i3
have a slower clock speed then i5 without Turbo Boost.
What is i3,i5, i7 & i9 ?
60. Amity School of Engineering & Technology
i7 Core i7 processors were introduced in 2008 and is
aimed at businesses and power users with 2-6 cores
(processors). As you might expect, the i7 features more
cache, more clock speed, and often more cores.
i5 Core i5 processors first appeared in 2009, It may have
2-4 cores (processors) with turbo boost. Turbo Boost
allows faster speeds when the processor is under high
demand. Other advantages included better memory
support. Hyper-threading.
61. Amity School of Engineering & Technology
i9 Core i9 processors were introduced in 2017 and feature a
high number of cores, high power draw, high thermal output,
and high performance. They are intended to be used by
hardcore gamers and enthusiasts. They are also the most
expensive processors.
62. Amity School of Engineering & Technology
Stock Keeping Unit or part number: SKUs are generally
assigned in the order in which processors in that generation and
product line are developed. SKU numbers are not recommended
for comparison across different generations or product lines
Product Line Suffix: These remaining differences are indicated
by a letter-based product line suffix. For example, within the
Intel® Core™ series, U indicates a processor that has been
designed for power-efficient laptops or 2-in-1s. Meanwhile, XE
indicates an “extreme edition” processor for desktops designed
for maximum performance.
63. Amity School of Engineering & Technology
Suffix Meaning
G1-G7 Graphics level (processors with new integrated graphics technology only)
F Requires discrete graphics (Require graphic card seperately)
G Includes discrete graphics on package
H High performance optimized for mobile
HK High performance optimized for mobile, unlocked
HQ High performance optimized for mobile, quad core
K Unlocked (You can overclock)
S Special edition
T Power-optimized lifestyle
U Mobile power efficient
Y Mobile extremely low power
64. Amity School of Engineering & Technology
Product
Name
Status
Launch
Date
# of Cores
Max Turbo
Frequency
Processor
Base
Frequency
Cache
Intel®
Core™
i9-
9980HK
Processor
Launched Q2'19 8 5.00 GHz 2.40 GHz
16 MB
Intel®
Smart
Cache
Intel®
Core™
i9-9880H
Processor
Launched Q2'19 8 4.80 GHz 2.30 GHz
16 MB
Intel®
Smart
Cache
Intel®
Core™
i9-9900T
Processor
Launched Q2'19 8 4.40 GHz 2.10 GHz
16 MB
Intel®
Smart
Cache
Intel®
Core™
i9-
9900KS
Processor
Launched Q4'19 8 5.00 GHz 4.00 GHz
16 MB
Intel®
Smart
Cache
67. Amity School of Engineering & Technology
A Process is a isolated memory structure which supports an
application in OS hardware and software. A Windows Process
contains 1 or more Threads
A Thread is a stream of sequential machine-code instructions
that the processor executes. With the exception of Interrupts,
Any time the CPU runs an Instruction on behalf of an
application, it does so because a thread contained it. Threads
within a process may access the processes memory (to the
extent that the specific operation on the memory element is
"thread-safe" and doesn't present
unreconciled concurrency issues when more than one thread
is run simultaneously). An Application may speed its operation
by using multiple threads, each performing an isolated task by
running their stream of instructions through a different
CPU Execution unit (CPU/core/virtual core) simultaneously.
68. Amity School of Engineering & Technology
Handles represent system resources like files, registry
keys, and threads. Threads: The number of active threads
in a process.
A Handle is a logical association with a shared resource like a
file, Window, memory location, etc. When a thread opens a file, it
establishes a "handle" to the file, and internally it acts like a
"name" for that instance of the file. Handles are used to link to
transitory or environmental resources outside the processes
memory structure.
69. Amity School of Engineering & Technology
Cache Memory
• The development of caches and caching is one of the most
significant events in the history of computing. Virtually every
modern CPU core from ultra-low power chips like the ARM
Cortex-A5 to the highest-end Intel Core i9 use caches.
70. Amity School of Engineering & Technology
How Caching Works
• CPU caches are small pools of memory that store information
the CPU is most likely to need next. Which information is
loaded into cache depends on sophisticated algorithms and
certain assumptions about programming code. The goal of the
cache system is to ensure that the CPU has the next bit of
data it will need already loaded into cache by the time it goes
looking for it (also called a cache hit).
• A cache miss, on the other hand, means the CPU has to go
scampering off to find the data elsewhere. This is where the
L2 cache comes into play — while it’s slower, it’s also much
larger. Some processors use an inclusive cache design
(meaning data stored in the L1 cache is also duplicated in the
L2 cache) while others are exclusive (meaning the two caches
never share data). If data can’t be found in the L2 cache, the
CPU continues down the chain to L3 (typically still on-die),
then L4 (if it exists) and main memory (DRAM).
71. Amity School of Engineering & Technology
How Cache Design Impacts Performance
• The performance impact of adding a CPU cache is directly
related to its efficiency or hit rate; repeated cache misses can
have a catastrophic impact on CPU performance. The
following example is vastly simplified but should serve to
illustrate the point.
• Imagine that a CPU has to load data from the L1 cache 100
times in a row. The L1 cache has a 1ns access latency and a
100 percent hit rate. It, therefore, takes our CPU 100
nanoseconds to perform this operation.
72. Amity School of Engineering & Technology
• Now, assume the cache has a 99 percent hit rate, but the data
the CPU actually needs for its 100th access is sitting in L2,
with a 10-cycle (10ns) access latency. That means it takes the
CPU 99 nanoseconds to perform the first 99 reads and 10
nanoseconds to perform the 100th. A 1 percent reduction in hit
rate has just slowed the CPU down by 10 percent.
• In the real world, an L1 cache typically has a hit rate between
95 and 97 percent, but the performance impact of those two
values in our simple example isn’t 2 percent — it’s 14 percent.
Keep in mind, we’re assuming the missed data is always
sitting in the L2 cache. If the data has been evicted from the
cache and is sitting in main memory, with an access latency of
80-120ns, the performance difference between a 95 and 97
percent hit rate could nearly double the total time needed to
execute the code.
73. Amity School of Engineering & Technology
What Happens When You Turn On Your
Computer?
When you power on a computer, it goes through a “boot up”
process– a term that comes from the word
“bootstrap.” Here’s what’s happening in the background—
whether you’re using a Windows PC, Mac, or Linux system.
74. Amity School of Engineering & Technology
When you press the power button, the computer
supplies power to its components—the motherboard,
CPU, hard disks, solid state drives, graphics processors,
and everything else in the computer.
In the past, the PC loaded something called a BIOS
(Basic Input/Output System.) On modern PCs, the CPU
loads UEFI (Unified Extensible Firmware
Interface) firmware instead. This is a modern
replacement for the old-style BIOS. But, to avoid
confusion, some PC manufacturers still call their UEFI
software “BIOS” anyway.
75. Amity School of Engineering & Technology
The CPU runs the UEFI or BIOS, which tests and initializes
your system’s hardware—including the CPU itself. For
example, if your computer doesn’t have any RAM, it will
beep and show you an error, stopping the boot process.
This is known as the POST (Power On Self Test) process.
You may see the PC manufacturer’s logo appear on your
screen during this process, and you can often press a
button to access your BIOS or UEFI settings screen from
here. However, many modern PCs fly through this process
so fast that they don’t bother displaying a logo and require
accessing their UEFI setting screen from the Windows
Boot Options menu (Advanced options).
77. Amity School of Engineering & Technology
The UEFI or BIOS looks for a “boot device” to boot your
operating system from. This is usually your computer’s hard
disk or solid-state drive, but may also be a CD, DVD, USB
drive, or network location. The boot device is configurable from
within the UEFI or BIOS setup screen. If you have multiple boot
devices, the UEFI or BIOS attempts to hand off the startup
process to them in the order they’re listed. So, for example, if
you have a bootable DVD in your optical drive, the system
might try starting from that before it tries starting from your hard
drive.
78. Amity School of Engineering & Technology
Traditionally, a BIOS looked at the MBR (master boot
record), a special boot sector at the beginning of a disk.
The MBR contains code that loads the rest of the operating
system, known as a “bootloader.” The BIOS executes the
bootloader, which takes it from there and begins booting the
actual operating system—Windows or Linux, for example.
The bootloader is a small program that has the large task
of booting the rest of the operating system. Windows uses
a bootloader named Windows Boot Manager
(Bootmgr.exe), most Linux systems use GRUB, and Macs
use something called boot.efi.
79. Amity School of Engineering & Technology
The OS loader loads essential hardware drivers that are
required to run the kernel—the core part of the Windows
operating system—and then launches the kernel. The
kernel then loads the system Registry into memory and
also loads any additional hardware drivers that are marked
with “BOOT_START,” which means they should be loaded
at boot. The Windows kernel then launches the session
manager process (Smss.exe), which starts the system
session and loads additional drivers. This process
continues, and Windows loads background services as well
as the welcome screen, which lets you sign in.
80. Amity School of Engineering & Technology
Definition
An Operating System, or OS,
is software that enables a
user and application software
to interact with a computer’s
hardware and the data and
other programs stored on the
computer.
An OS performs basic tasks,
such as recognizing input
from the keyboard, sending
output to the display screen,
keeping track of files and
directories on the disk, and
controlling peripheral devices
such as printers.
81. Amity School of Engineering & Technology
An operating system is the primary software that
manages all the hardware and other software on a
computer. The operating system, also known as an “OS,”
interfaces with the computer’s hardware and provides
services that applications can use.
What is operating System?
Operating systems also include a lot of software—things
like common system services(Program execution I/O
operations ,File System manipulation, Communication Error
Detection), libraries (like .dll(dynamic link libraries) files),
and application programming interfaces (APIs) (Win32 API
) that developers can use to write programs that run on
the operating system.
What is operating System in technical terms?
82. Amity School of Engineering & Technology
Need for an OS
• The primary need for the OS arises from the fact that
user needs to be provided with services and OS ought
to facilitate the provisioning of these services.
• The central part of a computer system is a processing
engine called CPU. A system should make it possible
for a user’s application to use the processing unit.
• A user application would need to store information. The
OS makes memory available to an application when
required.
• Similarly, user applications need use of input facility to
communicate with the application. This is often in the
form of a key board, or a mouse or even a joy stick (if
the application is a game for instance).
83. Amity School of Engineering & Technology
• The output usually provided by a video monitor or a printer as some times the
user may wish to generate an output in the form of a printed document.
Output may be available in some other forms. For example it may be a video
or an audio file.
Let us consider few applications.
• Document Design
• Accounting
• E-mail
• Image processing
• Games
We notice that each of the above application requires resources for
• Processing information
• Storage of Information
• Mechanism to inputting information
• Provision for outputting information
These service facilities are provided by an operating system regardless of the
nature of application.
84. Amity School of Engineering & Technology
• The OS offers generic services to support all the
above operations. These operations in turn
facilitate the applications.
• To that extent an OS operation is application
neutral and service specific.
85. Amity School of Engineering & Technology
Other Services
Program Execution
OS provides an environment where the user can conveniently run
programs. The user does not have to worry about memory
allocation or CPU scheduling.
I/O Operations
Each program requires input and produces output. The OS hides
some of the details of the underlying hardware for such I/O. All the
user sees is that the I/O has been performed, without those details.
Communications
There are instances where processes need to communicate with
each other to exchange information. It may be between processes
running on the same computer or running on different computers.
The OS provides these services to application programs, making
inter-process communication possible, and relieving the user of
having to worry about how this accomplished.
86. Amity School of Engineering & Technology
Application programs and OS
Operating systems provide a software platform on top of which other
programs, called application programs, can run.
The choice of operating system, therefore, determines to a great
extent the applications a user can run.
For example, the DOS operating system contains commands such
as COPY and RENAME for copying files and changing the names of
files, respectively. The commands are accepted and executed by a
part of the operating system.
Similarly, the UNIX operating system has commands like CP and
MV to copy and rename.
87. Amity School of Engineering & Technology
User and System View:
• From the user point of view the primary consideration is always the
convenience. It should be easy to use an application. In launching an
application, it helps to have an icon which gives a clue which application it
is. We have seen some helpful clues for launching a browser, e-mail or
even a document preparation application.
• In other words, the human computer interface which helps to identify an
application and its launch is very useful. This hides a lot of details of the
more elementary instructions that help in selecting the application.
Similarly, if we examine the programs that help us in using input devices
like a key board – all the complex details of character reading program are
hidden from the user. The same is true when we write a program. For
instance, when we use a programming language like C, a printf command
helps to generate the desired form of output. The following figure
essentially depicts the basic schema of the use of OS from a user stand
point.
88. Amity School of Engineering & Technology
UNIX
UNIX was one of the first operating systems
to be written, in 1971.
Advantages of UNIX are…
Multitasking – multiple programs can run at
one time.
Multi-user – allows more than a single user
to work at any given time. This is
accomplished by sharing processing time
between each user.
Safe – prevents one program from
accessing memory or storage space
allocated to another program, and enables
file protection, requiring users to have
permission to perform certain functions,
such as accessing a directory, file, or disk
drive.