CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user...
Transcript of CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user...
![Page 1: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/1.jpg)
CSS307-System ProgrammingSuleyman Demirel University
Fall 2015by Konstantin Latuta & EN3[ABCD]04
Summary of week 1, 2 and 3
![Page 2: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/2.jpg)
Outline
● Big picture of relevant knowledge areas● Hardware organization of computer system● Operating system concepts● UNIX history and concepts● Introduction to Linux● Why to study System Programming● Grading policy and syllabus
![Page 3: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/3.jpg)
UNIX/Linuxsystem programming
computer organization& architectureoperating systems
concepts
working knowledgeof UNIX/Linux
and C programming
relevant knowledge areas
our class
![Page 4: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/4.jpg)
Hardware Organization of Computer System
A modern computer system by A. Silberschatz et al, “Operating Systems Concepts: Essentials”
![Page 5: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/5.jpg)
Hardware Organization of Computer System
![Page 6: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/6.jpg)
Hardware Organization of Computer System
● Buses– collection of electrical conduits that carry bytes of information back
and forth between the components
– transfer fixed-sized chunks of bytes known as words, for example 32 bits or 64 bits
● I/O devices– Keyboard, mouse, display, disk drive, network adapter
![Page 7: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/7.jpg)
Hardware Organization of Computer System
● Main memory– temporary storage device that holds both a program and the data it
manipulates while the processor is executing the program
– DRAM
● Processor (Central Processing Unit)– the engine that interprets (or executes) instructions stored in main memory.
– contains a set of registers that helps it operate
– Arithmetic Logical Unit inside the CPU operates on registers and stores a result back to registers
![Page 8: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/8.jpg)
The truth about memory...
![Page 9: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/9.jpg)
Cache...
![Page 10: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/10.jpg)
Computer system is not just hardware
![Page 11: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/11.jpg)
Operating Systems Concepts
● OS has 2 main goals– To protect the hardware from misuse by application programs...
– To provide applications with simple and uniform mechanisms for manipulating complicated and often wildly different low-level hardware devices
● The goals are achieved by several abstractions– processes, virtual memory and files
![Page 12: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/12.jpg)
Abstractions provided by operating system
![Page 13: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/13.jpg)
Process
● A process is the operating system’s abstraction for a running program– Illusion of exclusive use of the processor, main memory, and I/O
devices
![Page 14: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/14.jpg)
Virtual Memory
● An illusion provided to process that it has an exclusive use of the main memory.– each process has a uniform view of
memory called virtual address space
![Page 15: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/15.jpg)
Files
● A file is a sequence of bytes, nothing more and nothing less– every I/O device, including disks, keyboards, displays, and even
networks, is modeled as a file
![Page 16: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/16.jpg)
UNIX OS
● A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs.– multi-user: when two or more people can work on the same computer at the
same time, using different terminals● A terminal is a device with a monitor and a keyboard. (The concept is more complex
than this, but for now think of it this way. There are also special windows called pseudo-terminals.)
– multi-tasking: when two or more programs can be running on the computer at the same time
● but it does not mean there has to be more than one processor; programs may timeshare the processor
![Page 17: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/17.jpg)
Why all the fuss about UNIX?
● UNIX is a professional operating system that lets you do sophisticated tasks easily
● It lets you customize your work environment and create new commands
● It is inherently very secure because of the way it was designed● Linux is a UNIX-like operating system that is very popular
![Page 18: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/18.jpg)
Why UNIX became popular?
● Portable– because it was written mostly in C (a new idea for that time)
● Very small– 10,000 lines of C, and about 1,000 lines of assembler
● Free– it was distributed to universities and research laboratories for free by AT&T
● Innovative– it had many features that were not part of any other operating systems such as
shells, pipes, files etc.
![Page 19: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/19.jpg)
User interfaces
● Graphic User Interface (GUI)● Command Line Interface (CLI)
– shell is a program that uses terminal device to bridge user and kernel
– kernel is the main part of any OSthat controls hardware etc.
kernel shell
![Page 20: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/20.jpg)
A word to creators of UNIX
● The success of UNIX lies not so much in new inventions but rather in the full exploitation of a carefully selected set of fertile ideas, and especially in showing that they can be keys to the implementation of a small yet powerful operating system.– Ken Thompson, Dennis Ritchie
● fertile ideas– files and file hierarchy, processes, users and groups, priviledged and
non-priviledged instructions, environments, device independent input/output...
![Page 21: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/21.jpg)
![Page 22: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/22.jpg)
Linux OS
● Linux is a free open source operating system initially intended for Intel x86-based PCs
● 1991, Linus Torvalds, a student in Helsinki started writing his own OS kernel, known as Linux kernel
● 1992, Linux was re-licensed with General Public License (GPL) by GNU (a project of Free Software Foundation which promotes free software)
● Mid-90s, Linux distributions emerged● 1998, major companies announced support
![Page 23: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/23.jpg)
Linux Philosophy
● Linux is a free and open source version of UNIX● Linux is maintained by a network of developers from all
over the world● Hierarchical filesystem with the top node / (aka root)● Everything is a file (or a file-like object)● Fully multitasking and multiuser OS
https://www.youtube.com/watch?v=H7Uz692S6T4https://www.youtube.com/watch?v=RaFNXQ8Dat0https://www.youtube.com/watch?v=_C-GAkLPAAc
![Page 24: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/24.jpg)
Linux Distributions
● Linux kernel is the core of a computer operating system (www.kernel.org)
● Linux distribution = kernel + some software tools– File management, user management, software package management
tools
● commercially supported distributions: Red Hat, SUSE, Ubuntu● free: CentOS, Fedora, Ubuntu, openSUSE● And many others like Scientific Linux, Oracle Linux etc.
![Page 25: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/25.jpg)
Distro Families
![Page 26: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/26.jpg)
Debian Family Key Facts
● The Debian family is upstream for Ubuntu, and Ubuntu is upstream for Linux Mint and others.
● The Linux kernel 3.13 is used in Ubuntu 14.04.● It uses the DPKG-based apt-get package manager
(we cover in more detail later) to install, update, and remove packages in the system.
● Ubuntu has been widely used for cloud deployments.● While Ubuntu is built on top of Debian, it uses the
Unity graphical interface, is GNOME-based and differs quite a bit visually from the interface on standard Debian as well as other distributions.
![Page 27: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/27.jpg)
Fedora Family Key Facts
● The Fedora family is upstream for CentOS, RHEL, and Oracle Linux.
● The Linux kernel 2.6.32 is used in RHEL/CentOS 6.x● It supports hardware platforms such as x86, x86-64,
Itanium, PowerPC, and IBM System z.● It uses the RPM-based yum package manager (we
cover in more detail later) to install, update, and remove packages in the system.
● RHEL is widely used by enterprises which host their own systems.
![Page 28: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/28.jpg)
SUSE Family Key Facts
● SUSE Linux Enterprise Server (SLES) is upstream for openSUSE.
● The Linux kernel 3.11 is used in openSUSE 12.3.● It uses the RPM-based zypper package manager
to install, update, and remove packages in the system.
● It includes the YaST (Yet another System Tool) application for system administration purposes.
● SUSE is widely used in the retail sector.
![Page 29: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/29.jpg)
System Programming
● System programming is the practice of writing system software● System software lives at a low level, interfacing directly with the
kernel and core system libraries● Kernel is the only software that runs all the time on computer
– it is the core of operating system with everything else being system or application software
![Page 30: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/30.jpg)
Why to learn system programming?
● System programmers develop an acute awareness of the hardware and the operating system on which they work
● Application programmers write in Java, JavaScript etc. but someone still has to write the JavaScript interpreter and the Java VM
● Developer writing Python or Ruby or Scala can still benefit from knowledge of system programming, as an understanding of the soul of the machine
![Page 31: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/31.jpg)
Grading Policy and Tentative Syllabus
● 40% Labs and Quizzes● 20% Midterm exam● 20% Final Exam● 20% creative t-shirt project● Portal View:
– 30% = L&Q/2 + M/2
– 30% = L&Q/2 + M/2
– 40% = F + t-shirt
![Page 32: CSS307-System Programminginstructor.sdu.edu.kz/~konst/sysprog2015fall/... · UNIX OS A multi-user and multi-tasking operating system that dates back to 1969 at AT&T Bell Labs. –](https://reader035.fdocuments.us/reader035/viewer/2022070917/5fb7e167028c7f0590432246/html5/thumbnails/32.jpg)
References
● Operating Systems Concepts Essentials, 2nd edition, Abraham Silberschatz et al., 2014
● Computer systems: a programmer’s perspective, Randal E. Bryant, David R. O’Hallaron, 2nd edition, 2011
● UNIX Application and System Programming lecture notes, Steward Weiss, 2013
● Linux Foundation course on edX.org● Linux System Programming, 2nd edition, Robert Love, 2013● Understanding UNIX/Linux programming, Bruce Molay, 2003