COMP 3000 Operating Systems
Introduction to Operating Systems (part 2)
Lianying Zhao
User Interface
• Command line (not inferior!)
• Text UI
• E.g., the “Green Screen Monster” – Mainframes • DOS, etc.
• GUI (Graphical User Interface) • E.g., X-Window
COMP 3000 (Winter 2021) 2
Security & Robustness
• Containing errors
• Application crashes
• Segmentation fault (command line, Linux) • “has stopped working” (Windows)
• Last resort: throwing errors • BSOD (Windows)
• Kernel panic (Linux) • Guru Meditation
COMP 3000 (Winter 2021) 3
Supervisor Mode vs. User Mode
• Kernel space, kernel mode, privileged • Runs at Ring 0 on x86
• Can do anything* in the traditional OS setting • OS kernel
• Device drivers
• User space, user mode, userland, unprivileged, • Runs at Ring 3 on x86
• No I/O accesses, e.g., file reads/writes, network interface, peripherals • No access to sensitive system states
• Contained by the privileged, usually in processes
COMP 3000 (Winter 2021) 4
Processes
• What a process actually is:
• A virtualized version of the CPU
• A virtualized version of the memory (i.e., address space)
• Distinguish from a program binary (e.g., .exe)
• What constitutes a process: • A unique identifier (PID)
• Memory image • CPU context
• I/O resources
COMP 3000 (Winter 2021) 5
Lifecycle of a Computer Program
Source code: hello.c
Object code: hello.o
Executable: hello
compile
link
Other object or static libraries
COMP 3000 (Winter 2021) 6
Users
• What is a user to the OS? • Just a label (number)
• Again, a unique identifier (UID)
• Purposes? Accountability, security, etc.
• Understand the user root (≈Administrator on Windows) • Merely a user, but special
• UID = 0
• Not almighty and not to be confused with Ring 0 (on x86)
COMP 3000 (Winter 2021) 7
Files
• Just ways of organizing data
• A linear array of bytes, each of which you can read or write
• Usually residing on persistent (non-volatile) storage devices **
• Structure & semantics
• Not the responsibility of the OS, but file users (e.g., applications)
• File systems
• Ways of organizing files • E.g., ext4, NTFS, FAT32… • Virtual File System (VFS)
Everything can be a file!
COMP 3000 (Winter 2021)
19
Source: Wikipedia
Function Calls, Library Calls and System Calls
• Within a process:
• Direct function invocation
• Function calls are within the initial loaded memory image, while dynamic library calls are with the help of the OS (dynamically mapping new code in)
• Both are the same, in terms of context
• Again: processes (user space) cannot do anything with the outside
• System calls are a major way (among others) for a process to talk to the outside and request OS services
COMP 3000 (Winter 2021) 9
System calls -> POSIX -> library calls (portability)
• For end users and app developers: system calls are not very useful
• Different extents of portability • OS-level
• Library-level
• POSIX: a family of standards that specify the various OS interfaces • Officially or almost complied with be most *nix operating systems
• Unix, Linux, Minix, etc.
COMP 3000 (Winter 2021) 10
printf() as an Example
• printf(“Hello world!\n”);
• Provided as part of
• Prototype:
• Located in the standard C library, e.g., libc.so • Library call
• Invokes
• write(1, “Hello world!\n”, 13);
• The OS may redirect to
• The text terminal where the application runs
COMP 3000 (Winter 2021) 11
COMP 3000 Operating Systems
Misc.
COMP 3000 (Winter 2021) 12
Tutorials vs. Lectures vs. Assignments
• Conceptual model and technical specifics
• Will converge at different points
• Additional explanation will be posted for tutorials (with partial coverage in class)
• Code reading and modification (C)
• Tutorials→Assignments
• Problem solving
• Why tutorials are not graded based on correctness
• Technical assistance
COMP 3000 (Winter 2021) 13
Understanding our environment
Web portal
Instance 2 192.168.*.*
Instance 1 192.168.*.*
Floating IPs
134.117.*.* 134.117.*.* 134.117.*.* 134.117.*.* 134.117.*.* 134.117.*.* 134.117.*.*
Instance 3 192.168.*.*
Instance 4 192.168.*.*
Instance 5 192.168.*.*
The SCS Openstack cluster
Instance 6 192.168.*.*
Instance 7 192.168.*.*
Instance * 192.168.*.*
Carleton campus network
COMP 3000 (Winter 2021)
14
SSH
VPN
or access.scs.carleton.ca
Source: PikPng
Creating a Forwarding Connection w/o VPN
• If you don’t need to access the Openstack Web UI, you can take advantage of the SSH “jump” feature
• We can take this as a tutorial task or a mock assignment
• Also observe how things can vary across OSes and software versions
COMP 3000 (Winter 2021) 15