0% found this document useful (0 votes)
53 views

Lecture # 01 Introduction To System Programming

This document contains notes from the first lecture of a System Programming course. It introduces the differences between application and system programming, and discusses the system programmer's perspective of managing operating system resources. Key points covered include an overview of the course topics, which involve learning to use Linux OS services like file management, process scheduling, and inter-process communication. The lecture also explains how system calls allow a program to request privileged kernel operations by changing the CPU state and invoking a system call service routine.

Uploaded by

yohannes assefa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Lecture # 01 Introduction To System Programming

This document contains notes from the first lecture of a System Programming course. It introduces the differences between application and system programming, and discusses the system programmer's perspective of managing operating system resources. Key points covered include an overview of the course topics, which involve learning to use Linux OS services like file management, process scheduling, and inter-process communication. The lecture also explains how system calls allow a program to request privileged kernel operations by changing the CPU state and invoking a system call service routine.

Uploaded by

yohannes assefa
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Instructor: Arif Butt

Lecture # 01
Introduction to System Programming

Course: System Programming


Instructor: Amsalu Thomas

Department of Software Engineering

Addis Ababa Science & Technology University (AASTU) 1


Today's Agenda
● Course Information
● Application vs System Programming
● Discussion on course outline

Addis Ababa Science & Technology University (AASTU) 2


Course Info
● Required Textbook: Advanced Programming in UNIX Environment 
 3rd Edition  Ritchard Stevens 
● Prerequisites : Operating System, C Programming

Visit our Google class for:


● Lectures Slides

● Resources

Addis Ababa Science & Technology University (AASTU) 3


Application Programmer
VS
System Programmer
Perspective

Addis Ababa Science & Technology University (AASTU) 4


Application Programmer Perspective

getchar()
Program
Scanner putchar()

Speaker

USB Stick

Ethernet

int main()
{
int c;
while ((c = getchar()) != EOF)
putchar(c);
return 0;
}

Addis Ababa Science & Technology University (AASTU) 5


System Programmer Perspective

P9 P2
P11 P1
P10
P8 P3
Scanner
P4

Speaker P5
P7
P6
USB Stick

Ethernet

Lots of users
Lots and lots of programs
Lots of disk files
Lots of devices
Lots and lots and lots of connections

Who is managing all these resources and connecting various devices to correct programs

Addis Ababa Science & Technology University (AASTU) 6


System Programmer Perspective

P9 P2
P11 P1
P10
P8 P3
Scanner
P4

Speaker P5
P7
P6
USB Stick

Ethernet Operating System Kernel

Role of Operating System is to manage all these resources and to connect


various devices to the correct programs

Addis Ababa Science & Technology University (AASTU) 7


System Programmer Perspective

P9 P2
P11 P1
P10
P8 P3
Scanner
P4

Speaker P5
P7
P6
USB Stick

Ethernet Operating System Kernel

Addis Ababa Science & Technology University (AASTU) 8


System Programming
● Application programming aims to produce software which provides
services to the user, e.g., word processors, browsers, multi-media
applications, etc.
● System Programming aims to produce software which provides
services to computer hardware, e.g., disk defragmenter. The next step is
writing kernel code to manage main memory, disk space management,
cpu scheduling, and management of I/O devices through device drivers.
a.out Users
Applications

Library Call System Call AUI API


OS Kernel

Kernel Hardware
Addis Ababa Science & Technology University (AASTU) 9
System Programmer Perspective
● A system programmer write programs that may have to
acquire data
● from a file(s) (residing on a local or remote disc) that may
have been opened by some other user(s),
● from other programs running on the same or different
machine,
● from the operating system itself.

● After processing, the programs may have to write results


to a shared resource, which other processes are also
writing, or results may need to be delivered to another
process asynchronously, i.e., not when the process asked
for it, but at some later unpredictable time. The challenge is to
master these concepts.

Addis Ababa Science & Technology University (AASTU) 10


Operating System Services
Some important tasks a kernel performs are:
● File Management
● Process management
● Memory management
● Information management
● Signal handling
● Synchronization
● Communication (IPC)
● Device management
Two methods by which a program can make requests for services
from the Kernel:
● By making a system call (entry point built directly into the
kernel)
● By calling a library routine that makes use of this system call
Addis Ababa Science & Technology University (AASTU) 11
System Calls
A system call is thecontrolled entry point into the kernel code,
allowing a process to request the kernel to perform a privileged
operation.Before going into the details of how a system call works,
following points need to be understood:
● A system call changes the processor state from user mode to
kernel mode, so that the CPU can access protected kernel memory
● The set of system calls is fixed. Each system call is identified by a
unique number
● Each system call may have a set of arguments that specify
information to be transferred from user space to kernel space and
vice versa
Addis Ababa Science & Technology University (AASTU) 12
System Call Invocation

Addis Ababa Science & Technology University (AASTU) 13


System Call Invocation
Application Program glibc wrapper function
--- read(...)
1 {
--- ---
read(fd,buff,count); syscall(SYS_read,fd,buff,count);
–-- 2
–-- return;
--- 6 }

User Mode

Kernel Mode
System call Service routine Trap Handler 5
SYS_read() system_call:
{ ---
–-- ---
–-- --- 3
return error
} 4

Addis Ababa Science & Technology University (AASTU) 14


What we will do in this course?
In this course we shall learn to use the services provided by
the kernel using Linux OS API, and this is what the course
is all about
Chapter 1: Introduction, Preparing your tool box
Chapter 2: File, Information and Time Management
Chapter 3: Process Management and Scheduling
Chapter 4: UNIX IPC Tools
Chapter 5: Thread Management and Synchronization
Chapter 6: Network Programming

Addis Ababa Science & Technology University (AASTU) 15


Things to do!

If you have problems visit me in counseling hours


Addis Ababa Science & Technology University (AASTU) 16

You might also like