Course Introduction
Operating Systems Primer
CS-446/646
C. Papachristos
Robotic Workers (RoboWork) Lab
University of Nevada, Reno
Your Instructor
Christos Papachristos
Associate Professor
Department of Computer Science & Engineering
Robotic Workers Lab (https://www.roboticworkerslab.com/) - (RoboWork)
Research / Coding / SW Engineering for Field Robotics
MS in Electrical & Computer Engineering
PhD in Autonomous (Aerial) Robotics
WPEB - 309 (Office) or WPEB – 316/302 (the RoboWork Lab)
CS446/646 C. Papachristos
Course Rules
Grading Policy:
You cannot earn a C in the course without having earned a C on both:
Plus/Minus grading will be assigned as indicated in the Syllabus.
Grade re-scaling may be assigned based on an outstanding or inferior Final exam.
Note: Also, you cannot earn a passing grade (D-) in the course without a passing grade on both categories.
Class participation will be factored in. As per the University Administrative Manual (UAM) 3,020, students are expected to attend classes in which they are enrolled.
Component | Percentage |
Homework Assignments (Undergraduate) | 30% |
Homework Assignments (Graduate) | 25% |
Presentations (Graduate-only) | 5% |
Midterm Exam | 30% |
Final Exam | 40% |
CS446/646 C. Papachristos
Course Rules
Tasks & Responsibilities:
Weekly / Bi-Weekly Homework Assignments
Turn in via WebCampus! LATE submission policy:
Academic Dishonesty:
Cheating, plagiarism or otherwise obtaining grades under false pretenses constitute academic dishonesty according to the code of this university. Academic dishonesty will not be tolerated and penalties can include filing a final grade of "F"; reducing the student's final course grade one or two full grade points; awarding a failing mark on the coursework in question; or requiring the student to retake or resubmit the coursework. For more details, see the University of Nevada, Reno General Catalog.
(Also, refer to Academic Standards in course syllabus and online)
CS446/646 C. Papachristos
Course Rules
Tasks & Responsibilities:
Weekly / Bi-Weekly Homework Assignments
Turn in via WebCampus! LATE submission policy:
Academic Dishonesty:
Note:
There exist widely accessible and reliable tools to cross-compare you code:
vs your classmates’ code !
vs students’ code from previous semesters !
Semantic analysis and comparison means IT WILL CATCH similarly structured code, � even if you rename your variables / change indentation / etc. !
CS446/646 C. Papachristos
Course Rules
Academic Standards Policy for Writing Code – CSE Department:
CS446/646 C. Papachristos
Course Rules
Generative AI use is NOT allowed for any purpose :
CS446/646 C. Papachristos
Course Objectives
Theoretical Understanding of:
Gain a holistic understanding of the big picture:
Coding in / Bash Scripting – level application of relevant concepts
Learn some transferrable skills
CS446/646 C. Papachristos
Course Resources
Operating Systems – Three Easy Pieces
Operating System Concepts
Modern Operating Systems
Also, Webcampus - Slides developed following content of� i) Stanford CS 140 by David Mazières,� ii) Johns Hopkin’s CS 318 by Ryan Huang,� iii) Columbia Engineering W4118 by Junfeng Yang
CS446/646 C. Papachristos
Course Help
Course & Projects:
Teaching Assistants:
Md Omer Danish
Disability Services:
Any student with a disability needing academic adjustments or accommodations is requested to speak with the Disability Resource Center as soon as possible to arrange for appropriate accommodations.
CS446/646 C. Papachristos
Challenges
Get comfortable with:
The Linux environment. All code must compile & run on (X)Ubuntu (min version: 18.04)
Start with your Homework Assignments early on !
(X)Ubuntu systems available at the ECC (SEM 231) and WPEB Labs.
To access Ubuntu on one of those machines, you have to hard restart the computer by pushing the
button on the tower, and then select CS135 from the available partition options.
Don’t wait to seek help. Benefit from all sources.
Your TA(s).
Your Instructor.
WebCampus material (Lectures, Samples, etc.) & Discussions.
CS446/646 C. Papachristos
Operating System Basics
What is an Operating System (OS)
Layer between Applications and Hardware
I.e. all the foundation on which you can develop your Programs/Apps.
Operating System
App(lication)
Hard
ware
CS446/646 C. Papachristos
Internet
Game
User
Operating System Basics
OS and Hardware
Management of Hardware Resources
Computation Volatile Storage Persistent Storage Communication I/O
Provides Abstractions to hide details of Hardware from Applications:
CS446/646 C. Papachristos
Operating System Basics
OS and Hardware
Mediates Access from different applications
Why?
Provides benefits to Applications by offering:
CS446/646 C. Papachristos
Operating System Basics
OS and Applications
Virtual Machine interface
Provides Protection
Provides Sharing
CS446/646 C. Papachristos
Operating System Basics
Different OSs
Numerous popular OS options exist
CS446/646 C. Papachristos
Operating System Basics
Requirements for a functional Operating System
A primitive OS idea:
Issues:
CS446/646 C. Papachristos
Applications
Hardware
Operating System
Operating System Overview
Multitasking
The ability for more than once Processes to be executing (running) at the same time
Note: Concurrently does NOT (necessarily) mean in parallel
Mechanism: Context-Switching
Requirements:
Avoid Processes going into infinite loop and never relinquishing CPU
Avoid Processes scribbling over each other’s data
CS446/646 C. Papachristos
Operating System Overview
Multitasking
The ability for more than once Processes to be executing (running) at the same time
Note: Concurrently does NOT (necessarily) mean in parallel
Mechanism: Context-Switching
CS446/646 C. Papachristos
Operating System Overview
OS Structure
CS446/646 C. Papachristos
Kernel
User
Network
Card
Console
Disk
Virtual Memory,
IPC, Scheduler,
Filesystem
Device Driver
Device Driver
Device Driver
Device File
Device File
Device File
Process 1
Process 2
Process …
Process N
Operating System Overview
User Mode (Unprivileged mode, Restricted mode, or Slave mode)
(User-Mode “bit”: 1)
Kernel Mode (Privileged mode, System mode, or Master mode)
(User-Mode “bit”: 0)
CS446/646 C. Papachristos
Note: E.g., CS (Code Segment) Register’s Current Privilege Level is 2-bit field corresponding to Privileges 0 (highest)-3(lowest). Linux only uses levels 0 & 3, respectively called Kernel Mode & User Mode.
Operating System Overview
System Call ( “Syscall” )
Applications can invoke the OS Kernel through System Calls
Note: In most OSs, no Context Switch is necessary (but a Privilege Switch occurs)
CS446/646 C. Papachristos
Kernel Space
User Space
User Application
System Call Interface
open( )
0xN
.
.
.
.
.
.
sys_open( )
Entry Point of open() System Call
.
.
.
return
#include <fcntl.h>
#include <unistd.h>
int main()
{
int fd = open("cs318.txt", O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd < 0) {
write(2, "Failed to open cs318.txt\n", 25);
_exit(1);
}
write(fd, "Hello, OS!\n", 11);
close(fd);
return 0;
}
System Call Dispatch Table
i.e. OS sets/unsets User Mode “bit”
Operating System Overview
System Call ( “Syscall” )
The only way for an application to invoke OS services
Goal: Do things application isn’t allowed to do in User Mode (Unprivileged)
Kernel supplies well-defined System Call Interface
Note: (from A Commentary on the 6th Edition Unix OS - 9 Hardware Interrupts and Traps):�“trap” Instructions may be deliberately inserted in user mode programs to catch the attention of the Operating System with a request to perform a specified service. This mechanism is used as part of the facility known as “System Calls”. (http://warsus.github.io/lions-/lionc/sect0116.html)
CS446/646 C. Papachristos
Operating System Overview
System Call ( “Syscall” )
C Standard Library calls are built on System Calls
CS446/646 C. Papachristos
Kernel Space
User Space
System Call Interface
write( )
0xN
.
.
.
.
.
.
sys_write( )
Entry Point of of write() System Call
.
.
.
return
#include <stdio.h>
int main()
{
printf("Hello, OS!\n");
return 0;
}
printf( )
System Call Dispatch Table
Standard C library ( libc )
Operating System Overview
System Call ( “Syscall” )
CS446/646 C. Papachristos
#include <unistd.h>
int main() {
write(1, "Hello\n", 6); // 1 is stdout
return 0;
}
C Example:
Assembly Example:
section .data
msg db "Hello", 0xa ; 0xa is \n
len equ $ - msg
section .text
global _start
_start:
mov rax, 1 ; sys_write system call number
mov rdi, 1 ; file descriptor (stdout)
mov rsi, msg ; address of string
mov rdx, len ; length of string
syscall ; invoke system call
mov rax, 60 ; sys_exit system call number
xor rdi, rdi ; exit code 0
syscall ; invoke system call
The Linux Syscall Table (for 64-bit Architectures)
Operating System Overview
Trap / Software Interrupt (“Interrupts” (of all types) sometimes also referred to as “Exceptions”)
Trap :
System Call ( “Syscall” ):
Both System Calls & Traps involve transferring control to the Kernel to perform Privileged operations, but:
C. Papachristos
Time for Questions !
CS-446/646
CS446/646 C. Papachristos