21
238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

238P: Operating Systems

Lecture 3: PC Hardware

Anton BurtsevJanuary, 2018

Page 2: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Recap from last time

Page 3: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Xv6 system calls

fork() Create a processexit() Terminate the current processwait() Wait for a child process to exitkill(pid) Terminate process pidgetpid() Return the current process’s pidsleep(n) Sleep for n clock ticksexec(filename, *argv) Load a file and execute itsbrk(n) Grow process’s memory by n bytesopen(filename, flags) Open a file; the flags indicate read/writeread(fd, buf, n) Read n bytes from an open file into bufwrite(fd, buf, n) Write n bytes to an open fileclose(fd) Release open file fddup(fd) Duplicate fdpipe(p) Create a pipe and return fd’s in pchdir(dirname) Change the current directorymkdir(dirname) Create a new directorymknod(name, major, minor) Create a device filefstat(fd) Return info about an open filelink(f1, f2) Create another name (f2) for the file f1unlink(filename) Remove a file

Page 4: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Processes

fork() Create a processexit() Terminate the current processwait() Wait for a child process to exitkill(pid) Terminate process pidgetpid() Return the current process’s pidexec(filename, *argv) Load a file and execute it

Page 5: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Files

open(filename, flags) Open a file; the flags indicate read/writeread(fd, buf, n) Read n bytes from an open file into bufwrite(fd, buf, n) Write n bytes to an open fileclose(fd) Release open file fd

Page 6: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

I/O redirection and interprocess communication

close(fd) Release open file fddup(fd) Duplicate fdpipe(p) Create a pipe and return fd’s in p

Page 7: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Memory

sbrk(n) Grow process’s memory by n bytes

Page 8: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Directories and named files

chdir(dirname) Change the current directorymkdir(dirname) Create a new directorymknod(name, major, minor) Create a device filefstat(fd) Return info about an open filelink(f1, f2) Create another name (f2) for the file f1unlink(filename) Remove a file

Page 9: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

OS implements this interface

Page 10: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

PC Hardware

Page 11: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

CPU

● 1 CPU socket● 4 cores● 2 logical (HT) threads each

Page 12: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Memory

Page 13: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Memory abstraction

● x86 assembly example:

mov eax, [ebx] ; Move 4 bytes in memory at the address contained in EBX into EAX

Page 14: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

I/O Devices

Page 15: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Multi-socket machines

Page 17: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

CPU execution loop

● CPU repeatedly reads instructions from memory

● Executes them● Example

ADD EDX, EAX, EBX // EDX = EAX + EBX

Page 18: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018
Page 19: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

CPU execution loop

● Fault● Instruction's

preconditions are not met

● Examples● Division by zero● Page not mapped

Page 20: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Memory hierarchy

Page 21: 238P: Operating Systems Lecture 3: PC Hardware › ... › lecture03-pc-hardware.pdf · 2018-09-27 · 238P: Operating Systems Lecture 3: PC Hardware Anton Burtsev January, 2018

Questions?