代写代考 COMP30023 – Computer Systems

COMP30023 – Computer Systems

© University of Melbourne 2022

Copyright By PowCoder代写 加微信 powcoder

Operating systems:
Process Management

• Last lecture: Operating Systems Overview
• Introduction to Processes and Process Management

© University of Melbourne

• Not putting “International” if you’re outside of Australia
• The authenticity of host ‘…’ can’t be established.

RSA key fingerprint is ….
Are you sure you want to continue connecting (yes/no)? yes

• Not specifying the correct (lowercase) username and ip
• Permission denied errors – not specifying the private key

(public key instead), corrupt private key
• Connect to university network or configure VPN

© University of Melbourne 3

Prelab: Common issues

– Provides an abstraction of hardware resources
– Manages these resources

© University of Melbourne 4

Operating system (OS)

One or more processors
Main memory
Network interfaces
I/O devices

• Central processing unit (CPU)
• Fetches instructions from registers (memory); executes

• Registers keep some process state information
• Two modes of execution:

– Kernel (execute any CPU instruction and reference any memory
address) e.g., initiate I/O

– User (only a subset) e.g., add, sub

© University of Melbourne 5

Processor/CPU

• A program is static; a process is dynamic.
• At any given time, the number of processes running a given

program can be 0, 1, 2, 3, …
• The state of a process consists of the code or “text” of the

program, the values of all the variables, both in memory
and in registers, the address of the current instruction, and
probably some other data as well (e.g. current directory).

• As an analogy, consider cooking:
• A recipe is a static entity; it is analogous to a program.
• The act of cooking is analogous to a process.

© University of Melbourne

Processes vs. processors

© University of Melbourne

How many processes do you think your machine
is running?

How many CPUs does your computer have?

Try ps -ef, lscpu, activity monitor etc. depending
on your machine.

• Program in execution
• Each process has its own address space
• Process memory has three segments:

– text (program code, usually “read only”)
– data (constant data strings, global vars)
– stack (local vars)

© University of Melbourne

Multiple processes

© University of Melbourne

• Conceptually each process has its own virtual CPU.
• In reality, multiple processes will share a CPU, each running for a

small period of time in turn. This is called multiprogramming.
• Introduced in 1960s: use CPU while waiting for I/O

4 processes running in “parallel”:

• Multiprogramming increases system efficiency. When one process
needs to wait for e.g. data from disk or keyboard input, another
process can make use of the CPU.

• Multiprogramming is useful even when the machine has two or
more CPUs, since (for the foreseeable future) the number of
processes will sometimes exceed the number of CPUs.

Multiprogramming

© University of Melbourne

4 processes running in “parallel”:

Multiple processes – a simple
illustration

© University of Melbourne

Each program has its own address space

Structures

OS Routines

Program code
Program global data

Program heap

Program stack

• If several processes are to be active at the “same” time,
something has to ensure that they do not get in each
other’s way.

• It provides services such as “read N bytes from this file”.
These services are used by application programs, utilities,
and by the non-privileged parts of the operating system.

Operating system as a process

© University of Melbourne

© University of Melbourne 13

• Most CPUs have two modes (some have more). The program
status word (PSW) register gives the current mode.
– Code running in user mode cannot issue privileged instructions, and can

access only the parts of memory allowed it by kernel mode code.
– Code running in kernel mode can issue all instructions, and can access

all memory.

• Instructions and memory locations whose use could interfere
with other processes (e.g. by accessing I/O devices) are
privileged.

• The user mode / kernel mode distinction is the foundation
needed by the OS for the building of its security mechanisms.

User-kernel mode distinction

© University of Melbourne

Mode bit (in program status word register) provided by
hardware. It provides the ability to distinguish when the
system is running in user mode or kernel mode.

Transition from User to Kernel mode

© University of Melbourne

• System calls exist to allow user programs to ask the OS to execute
privileged instructions and access privileged memory locations on
their behalf. Since the OS checks those requests before executing
them, this scheme preserves system integrity and security.

• To make system calls more convenient to use, a system call will
typically do several privileged things in carrying out one logical
operation, e.g. reading N bytes from a file on disk.

• To the application programmer, a system call is a call to a
privileged function.

• Example system calls on Unix:
– open, read, write, close
– fork, exec, exit, wait

System calls

© University of Melbourne

• Process control, e.g.. load/execute; create and terminate a
process; get/set process attributes

• File management e.g.. create/delete/open/close/read from
a file; get/set file attributes

• Device management e.g.. request/release a device;
read/write from a device

• Information maintenance e.g.. get/set time or date
• Communication e.g.. create/delete communication

connections.

Typically system calls
(OS independent list)

© University of Melbourne

• Standard C library handling of write(). The library provides a
portion of the system-call interface for many versions of Unix and

System call example

© University of Melbourne

Processor vs. process
What is a process
Multiprogramming concept
User vs. kernel mode

• This class part 2: Source control (Git)
• Week 2: process lifetime, scheduling and interprocess

communication

© University of Melbourne 19

• The slides were prepared by based on
material developed previously by: , , , , , and .

• Some of the images included in the notes were supplied as
part of the teaching resources accompanying the text books
listed in lecture 1.
– (And also) Figures 1.10, 2.6, 2.11 of Modern Operating Concepts

• References: TB 1.3.1, 1.5.1, 1.6 (before 1.6.1), 2.1, 2.2.1

Acknowledgement

© University of Melbourne

– Processes (running program)
– Address spaces (memory)
– Files and file system
– Input and Output
– Protection (manage security)

© University of Melbourne 21

Operating system concepts

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com