CSO 101 Computer Programming
Lecture 1
IIT (BHU) CSE
Administrative Details
▷ Lectures, Tutorials and Lab
▷ Assignments – Lab, Theory and Quizzes
▷ Mid-Sem and End-Sem Exams (Online
Assignments)
▷ Programs can be run online or in desktop,
smartphones
▷ Online – Use GNU compiler – For example look at
-
▷ Desktop – Install gcc compiler
▷ Smartphone Apps – Coding C
Some History
▷ Computer technology made immense progress in
last 70 years - Cost of a computer in 1985 was 1
million dollars!!!
▷ In 1960’s computers were stored in multiple rooms
with operators overseeing their support – Used for
business data processing and large-scale scientific
computing
▷ Microprocessors came in 1970’s
▷ Desktop based microprocessors in 1980’s
▷ Emergence of Internet and World Wide Web in
1990’s
▷ Cellphones/smartphones (embedded computer)
Computer Architecture
Memory
Input Output
Devices CPU
Devices
▷ Input Devices – Keyboard, Mouse
▷ Output Devices – Monitor, Printer
▷ Central Processing Unit (CPU)
▷ Memory – Main, Secondary
Central Processing Unit (CPU)
▷ Brains of the Computer - E.g., Intel i7
▷ Decisions are made, computations are performed
▷ Contains three components
▷ Arithmetic Logic Unit (ALU) – Arithmetic and
logical operations are performed (in binary
system)
▷ Control Unit (CU) – Decodes and executes the
instructions
▷ Register Set – Store pointers, counters, return
address and other temporary data
Memory Unit
▷ Stores program and data processed by computer
▷ Types – Main, Secondary, Cache
▷ Main memory – Random Access Memory
(RAM)/Read Only Memory (ROM) -
Temporary/Permanent – Fast access
▷ Secondary memory – Hard disk, USB pen, DVD –
Permanent – Slower access
▷ Cache memory (Not to be confused with browser
cache) – Temporary – Very fast access – Expensive
▷ Note temporary/volatile means data is available
only till the power is on.
Operating System
▷ The software which runs the computer hardware
User
Application
programs
Operating system
Computer
hardware
More About Operating Systems (OS)
▷ Hides the hardware architecture and instruction
set
▷ Provides with standard instructions to work with
irrespective of the hardware
▷ Acts as a resource manager – allocation and
management of resources to programs
▷ Core of the OS is called kernel
▷ On top of this is a command line interpreter (CLI)
also called shell
▷ Some application programs like text editor also
come together with OS
Ok More About OS
▷ Note application programs can directly access kernel
services through system calls
▷ Common system calls – read, write, open, close, wait,
exec, fork, kill
▷ read, write, open, close: are for files – wait: process waits
for other process to complete – exec: execution of
process – fork: creates a copy of itself – kill: sends
termination signal to a process
▷ Also provides security – kernel mode/user mode
▷ Control over system performance
Examples of OS
▷ Some examples – UNIX/Linux, Windows –
▷ We also have other types like embedded OS and
real-time OS
▷ UNIX is a powerful multitasking, multiuser
operating system – 90% of world’s fastest
supercomputers
▷ Closely associated with C language
▷ Linux is open source (GNU), UNIX like
▷ Android has Linux kernel !!
Operating System Functions
▷ Process management
▷ Memory management
▷ File system management
▷ Device management
Process Management
▷ Program in execution is called process
▷ Each process has an address space (a list of
memory locations) used to store executable
program, its data and stack
▷ Scheduling of process – allocation of the processor
▷ Deadlock Avoidance – deadlock is the situation
when two or more processes get into a stalemate
situation
▷ Provides mechanism for inter-process
communication
Memory Management
▷ Deals with the main memory which has to be
shared between OS and application programs
▷ Keeps programs from the programs in interfering
with one another
▷ Management of programs address space (recall
what is an address space?)
▷ Concept of virtual memory – OS keeps part of the
address space in main memory and part in
secondary memory – Shuttles it back and forth as
needed
▷ Can you guess the need for virtual memory?
File system management
▷ Files systems are abstract organized collection of
files
▷ Provides system calls to create, read, write, close,
open, remove files
▷ Concept of directories where files are grouped
together – system calls to manage these
▷ Concept of pipes related to both process and file
management
▷ pipe is a pseudofile that connects two processes -
one can send data to another by writing into this
pseudofile
I/O Device Management
▷ Computer receives information through input and
output devices
▷ Processes access devices these using system calls
▷ Some part of it is device independent and others
device dependent called device drivers
▷ Device driver controls/operates a particular device
like keyboard or monitor – It’s’ a software interface
to OS and application programs to use the device
without knowing details about hardware
▷ Devices are efficiently shared among requiring
them
▷ In UNIX I/O devices are also viewed as files!!
High-Level Programming Language
▷ Provides strong abstraction from the details of the
computer
▷ Easier to use, or may automate or hide significant
areas of computing systems (e.g. memory
management)
▷ Makes the process of developing a program simpler
and more understandable relative to a lower-level
language
▷ Structured – code can be divided into smaller units
or blocks
▷ Unstructured – single continuous or unbroken block
Assembly Code
▷ Assembly Language – Mnemonics and memory
addresses
▷ How it looks like?
LD Acc, #12836 ;
ADD [37846] ;
STO Acc, 45632 ;
:loop ;
Machine Code
Instructions are sequences of binary numbers
0010011010011001
1101010011100101
1100010101001010
0100101101010010
Compiler and Interpreter
▷ Compiler: Translates source code from a high-level
programming language to a lower level language
(e.g., assembly language, object code, or machine
code) Executa
Source
ble file:
file Compiler
Hello.ex
Hello.c
e
▷ Interpreter:
▷ It’s a computer program that directly executes
▷ Performs, instructions written in a programming or
scripting language without previously compiling
into a machine language program
Integrated Development Environment
(IDE)
▷ IDE - Software application that provides
comprehensive facilities to computer programmers
for software development.
▷ IDE typically consists of a source code editor, build
automation tools (compiler) and a debugger.
▷ For C language : Code::Blocks,Visual Studio
Screenshot of an IDE
Some References for the course
▷ For C Language:
▷ Programming in ANSI C – Balagurusamy
▷ Let Us C – Kanetkar
▷ C Programming Language – Kernighan and Ritchie,
▷ C in Hindi – Kuldeep Chand
▷ For basics to be covered this week:
▷ Online resources like geeksforgeeks, tutorialspoint
and several youtube channels