1 / 79

CSL101: Introduction to Computers and Programming: Lecture 1

CSL101: Introduction to Computers and Programming: Lecture 1. Instructors: Saroj Kaushik and Vinay Robeiro Prof Saroj Kaushik (Groups 1 to 3) Room No : 416, Bharati School building (CSE) Phone Number: 1292 (internal) Email : saroj@cse.iitd.ernet.in

jorjanna
Download Presentation

CSL101: Introduction to Computers and Programming: Lecture 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSL101: Introduction to Computers and Programming: Lecture 1 Instructors: Saroj Kaushik and Vinay Robeiro Prof Saroj Kaushik (Groups 1 to 3) Room No : 416, Bharati School building (CSE) Phone Number: 1292 (internal) Email : saroj@cse.iitd.ernet.in Web Link : http://www.cse.iitd.ac.in/~saroj Dr Vinay Rabeiro (Groups 6 to 10) Room No : 421, Bharati School building (CSE) Phone Number: 1297 (internal) Email : vinay.ribeiro@gmail.com Web Link : http://www.cse.iitd.ac.in/~vinay

  2. 1st semester 2009-2010: Time Table CSL101 Introduction to Computers and Programming

  3. Attendance • Compulsory • A test/quiz may be held on any day • Classes will begin on time • Cheating on exams and assignments • We follow 0-tolerance policy

  4. Course contents • “Problem solving using computers” as opposed to “Programming” • Concept of an algorithm • Developing algorithms: • Specification • Stepwise refinement • Data organization • Efficiency • Termination and correctness • Testing and de-bugging • Programming in a high level language: C • Syntax and semantics • Problem solving in science and engineering • Introduction to computer architecture, operating systems, compilers and application software

  5. Course structure • Minor 1 and 2, each has 15-20% weight • Major, 30-35% weight • Quizzes and home assignments, 5% • Programming exercises, 20-25% weight • 2 hr/week lab for each group • Location is Computer Services Centre • Lab exercises, rules, instruction on how / when / whom to submit will be posted on website http://www.cse.iitd.ac.in/~saroj • Note these weights are indicative, and may change as semester progresses

  6. Submission of lab reports • For each exercise there will be a deadline for submission of report/code. Be sure that you complete the exercise well before the deadline and submit the report in time. • We will not tolerate excuses (power fail, server down, printer fault, lab closed, etc.). • We will give you: • a grace period of 1 day, provided you are willing to accept a penalty of 10% of the marks assigned, or • a grace period of 1 week (7 calendar days), provided you are willing to accept a penalty of 50% of the marks assigned to the exercise.

  7. Text books • R. G. Dromey “How to solve it by computer”, Prentice Hall, Indian edition, 1999. • Brian W. Kernighan, Dennis Ritchie, C Programming Language (2nd Edition).

  8. Electronic Computers • Responsible for a revolution in almost all spheres of areas such as • Science • Engineering • Business • Management

  9. Types of Computers • Classified into three categories • Digital : Process digital information • Analog : Data is represented by physical quantities (pressure, speed, volume etc) • Hybrid : Combination of both • Generally by computer we mean digital computer

  10. Digital Computer • Capable of performing • arithmetic operations on numbers • logical operations on bits (binary digit) • decision test • retrieval, manipulation and storage of large amount of data at a very high speed

  11. Computer System • A computer system is made up of both • hardware and • software • Software is another term for computer program. • Software controls the computer and makes it do useful work. • Without software a computer is useless, just as a car without someone to drive it. • To get a computer to perform a specific task it must be given a sequence of unambiguous instructions called a program written in some programming language.

  12. Hardware components of a computer system are the electronic and mechanical parts. • It is the physical medium. • The major hardware components are: • Processor • Main memory & Secondary memory • Input devices (keyboard) • Output devices (printer) • The processor, main memory, and secondary memory devices are inside the system unit seen as metal box. • The keyboard and monitor (the TV-like screen) are input/output devices. • Hardware components also include • mouse, disk drive, soundcard and speakers • CD ROM drive (Read Only Memory), network card • floppy disc drive (for backing up data)

  13. Types of Computers • By 1980, computers were classified into three main types. • Main Frame: • Traditionally large computers, often containing thousands of IC’s and costing millions of dollars • High speed, large storage & highly accurate • can be shared by group of users • Mini Computers: • Smaller in size, slow in speed, low cost and can be shared by group of users • Micro Computers (Personal computer - PC): • New class of general purpose machines intended for single user. • Small in size and inexpensive

  14. The following schematic diagram gives the layout of a digital computer.

  15. CPU (Central Processor Unit) does the `work‘ of fetching, storing and manipulating data that are stored in the computers memory. • Main memory is used to store program and data during execution of a program. • Disc drive (hard or floppy) used to store files (program + data) `permanently‘. • Keyboard allows user to input information. • VDU (Visual Display Unit) visually outputs the data. • Printer allows a hard copy to be made.

  16. The current architecture of PC (personal Computer) is as follows (major hardware components ) • The arrows show the direction of data flow.

  17. The bus is a group of wires on the main circuit board of the computer through which electrical signal passes. • It is a pathway for data flowing between components. • Buses are of three types: • Address bus: • used to transmit address of memory location • Data bus: • Used to transmit data from/to memory • Control bus: • Supervises reading/writing of data • Most devices are connected to the bus through a controller. • Controller coordinates the activities of the device and the bus.

  18. Central Processing Unit (CPU) • The processor as its name suggests is the unit that does the work of the computer system i.e. • it executes computer programs. • Instructions in the program tell the processor • when and what to read from a keyboard; • what to display on a screen; • what to store and retrieve from a disk drive and so on. • It can do arithmetic, compare numbers and perform input/output. (read information and display or store it). • It has no magical powers. It is instructive to bear in mind that all computer programs are constructed from sequences of instructions based on such primitive operations.

  19. The processor itself is made up of a number of components such as the • arithmetic logic unit (ALU) and • control unit (CU). • The ALU carries out arithmetic operations (e.g. addition and subtraction) and logical operations (e.g. and, or, not) • The CU controls the execution of instructions. • Traditionally, the processor is referred to as the central processing unit or CPU. • With the advent of microprocessors, the term MPU or microprocessor unit is also used. • A microprocessor is simply a processor contained on a single silicon chip. • Processors come in all different `shapes and sizes' • There are many different types of architectures which are suited to a variety of different tasks

  20. Main Memory • Main memory is where programs and data are kept during execution that the processor is actively working with. • when the processor is actively using them. • Main memory is also called Random Access Memory (RAM) or primary memory. • "Random" means that the memory cells can be accessed in any order randomly. • Main memory is: • very closely connected to the processor. • the contents are quickly and easily changed. • interacts with the processor millions of times per second.

  21. Micro Computer Memory • It has two types of memory. • Random Access Memory (RAM) • Volatile • Random access to any memory location • Read & write access • Program + data reside in this memory • Read only Memory (ROM) • Non volatile • Only read access • Permanent programs reside

  22. Cache Memory • A special and very high speed memory used to increase the speed of processing. • It lies between CPU and main memory. • It is expensive and usually small in size. • Stores only segments of programs currently being executed by CPU. • It is also sometimes called buffer.

  23. Secondary memory • Connected to main memory through the bus and a controller. • The contents are easily changed, but this is very slow compared to main memory. • It is used for long-term storage of programs and data. • Common secondary storage devices are the hard disk and floppy disks and CDs.

  24. The hard disk • has enormous storage capacity compared to main memory (300 times the amount of storage in main memory). • storage capacity of 40/80 Gigabytes and Terabytes. • usually contained in the systems unit of a computer.

  25. Primary memory Fast Expensive Low capacity Connects directly to the processor Secondary memory Slow Cheap Large capacity Not connected directly to the processor Quick comparison of two types of storages:

  26. Some Basic Terminology • Bit is short for Binary Digit. • Bit has only two values represented as: 1 or 0, (on or off ; true or false), • Byte consists of 8 Bits. • 1 KB (1 KiloByte) contains 1024 Bytes. • 1 MB (1 MagaByte) consists of 1024 KB. • 1 GB (1 GigaByte) has 1024 MB. • 1 Terabyte consists of 1024 GB.

  27. Table of units of measurement

  28. Organization of Main Memory • Main memory consists of a very long list of bytes. • In most modern computers, each byte has an address.

  29. Each row is called memory location (single byte and has an address). • The addresses are the integers to the left of the boxes: 0, 1, 2, 3, 4, ... and so on. • The addresses for most computer memory start at 0 and go up in sequence until each byte has an address. • The address of a byte is not part of its contents. • The bits at a memory location are called the contents of that location. • Each location contains a pattern of eight bits, each bit is either 0 or 1. • By the term that a computer has "128 MB of RAM" they are talking about the size of memory.

  30. Groups of memory locations can be treated as a whole to allow more information to be stored. • All machines have a wordsize: a fundamental unit of storage, • For example, 8-bits, 16-bits, etc. • The size of a word (in Bytes) differs between machines. • A Pentium based machine generally has word size of 32-bits.

  31. The CPU can read to and write from a specified memory location. • Most processors can write (and read) more than a single byte at a time. • While writing a byte into a given location, the previous bit pattern is destroyed and the new contents (bit pattern) are saved for future use. • While reading a byte from a given location • The processor gets the bit pattern stored at that location. • The contents of that location are NOT changed.

  32. CPU also has a small number (usually less than 100) of storage locations to store information that are currently being processed. • These locations are called registers and depending on the processor, a register may typically store 8, 16, 32 or 64 bits. • Processors with a register size of • n-bits are called n-bit processors, • processors with 8-bit registers are called 8-bit processors, • similarly there are 16-bit, 32-bit and 64-bit processors. • CPU has several important registers • Memory address register (MAR) • Memory data register (MDR) • Program counter (PC) • Current instruction register (CIR) • Accumulator

  33. The greater the number of bits the more powerful the processor is, since it will be able to process a larger unit of information in a single operation. • For example, a 32-bit processor will be able to add two 32-bit numbers in a single operation whereas an 8-bit processor will only be able to add two 8-bit numbers in a single operation. • An n-bit processor will usually be capable of transferring n-bits to or from memory in a single operation. • This number of bits is also referredto as the memory word size. So, while a byte refers to an 8-bit quantity, a word can mean 8, 16, 32, 64 or some other number of bits. • On some machines a word is taken to mean a 16-bit quantity and the term long word is used to refer to a 32-bit quantity.

  34. Software • Software is a program and data that a computer uses. • Software is kept on some hardware device such as a hard disk or floppy disk for further use. • Programs are lists of instructions for the processor. • Data can be any information that a program needs. It could be: • character data, numerical data, image data, audio data, and countless other types. • The distinction between programs and data within the computer memory is not as clear-cut as you might think, however. • However both programs and data are saved in computer memory in the same way. • The electronics of computer memory (both main memory and secondary memory) make no distinction between programs and data.

  35. The programs and data can be saved using the same electronic methods. • This is one of the most important ideas in computer science. • Computer systems can use their memory for whatever needs arise. • A computer that is dedicated to running a program that controls another device is an embedded system. • An embedded system is usually embedded inside the device it controls. • Usually they run just one program that is permanently kept in a special kind of main memory called ROM (for Read Only Memory). • More processor chips are sold per year for embedded systems than for all other purposes

  36. Types of Programs • There are two categories of programs. • Application programs (usually called just "applications") are programs that people use to get their work done. • Systems programs keep all the hardware and software running together smoothly. It helps in developing application programs. • The difference between "application program" and "system program" is fuzzy. • Often it is more a matter of marketing than of logic.

  37. Application Programs Word processors Game programs Spreadsheets Data base packages Graphics programs Web browsers Systems Programs Operating system. Networking system. Database system. Compilers Web site server. Data backup.

  38. Operating Systems (OS) • The operating system is a complex collection of many programs that governs the control of various resources such as: • Processor • Main Memory • Secondary storage • I/O devices • Files • The operating system is software; the same hardware can be used with many different operating systems (although only one at a time.)

  39. Modules of OS • The operating system is always present when the computer is running. • It coordinates the operation of all the hardware and software components of the computer system. • The operating system is responsible for starting application programs running and finding the resources that they need. • The operating system manages the details of the resources an application requires while it is running.

  40. There are various modules of OS • Processor management • Memory management • Device management • Information management • These modules resolve conflicts, optimize performance and acts as an interface between the user’s program and computer hardware. • Modern operating systems usually come with a user interface that enables users to easily interact with application programs by using windows, buttons, menus, icons, the mouse, and the keyboard.

  41. Examples of operating systems are DOS, Unix, Windows 98, Windows NT, Linux, Solaris, etc. • There are different OS for different kinds of machines. • Single user machine • Batch processing • Multiprogramming • Time sharing • Real time machines

  42. Problem solving using computers • Problem definition • Method (how to solve it) • Algorithm • Data structure • Verification for correctness • Analysis for efficiency • Coding in given “programming language” • Understanding of computer “architecture” • “Compilation”, “testing”, “de-bugging” • Documentation

  43. Problem definition • Most difficult • Requires interaction between “programmer” and user • Specs include: • Input data • Type, accuracy, units, range, format, location, sequence • Special symbols to signal end of data • Output data (results) • type, accuracy, units, range, format, location, “headings” • How is output related to input • Any special constraint • Example: “find the phone no. of a person” • Problems get revised often

  44. Algorithm • It is a finite set of instructions which, if followed accomplish a particular task. • It is basically used to describe a problem solving method suitable for implementation as a computer program. • Algorithm is independent of the machine and language used for implementation.

  45. Characteristics of an Algorithm • Input • Zero or more quantities are supplied externally • Output • At least one quantity is produced • Definiteness • Each instruction is clear & unambiguous • Finiteness • It terminates after finite steps • Effectiveness • Each instruction is simple to be carried out manually.

  46. Algorithms(1) • An “unambiguous specification of a method” • Is characterized by: • Ordered sequence of well-defined, effective operations that, when executed, will produce a result after “terminating” within a finite no of steps

  47. Algorithms (2) • Well-defined and effective • No ambiguity, a method must exist • Good Examples: Add 1 to x compute largest prime no. < 100 compute square root of x to 4 decimal places • Bad examples: divide 10 by x compute largest prime compute square root of x

  48. Algorithms (3) • Always terminate, and be sure about it • Produce correct results • this may require some hard thinking • testing helps, but is not adequate

  49. Algorithm verses Program • Basic differences are: • Program is written in programming language whereas algorithm is in English like pseudo language. • Program may be non terminating (OS) whereas algorithm should terminate in finite steps.

  50. Study of algorithm can be classified in four distinct areas namely how to • devise • express • validate • analyze algorithms

More Related