Exam 1 review

¡Supera tus tareas y exámenes ahora con Quizwiz!

Characteristics of kernel mode

- Direct access to hardware - Can run any instructions on hardware - One program that is running at all times on computer

What is an operation system?

- Layer of software - provide users with a simpler interface - hide the details of hardware components from users - manages computer resources and function

A Little Endian computer means that _____________

- Memory words read starting from the Least Significant bits OR - he bits are ordered from least significant to most significant

Explain the program layout in memory

- Text segment - holds code - data segment - heap area used for dynamic allocation and stack area used for function calling and storing data/variables in the memory - OS/ kernel space

Multiprogramming

- When one job needs to wait for I/O, the processor can switch to the other job, which is likely not waiting for I/O - While one program waits for user input, switch to a different program

Component of a process

- an executable program - the associated data needed by the program (variables, work, space, buffers, etc.) - the execution context (or "process state") of the program

An instance of a program includes...

- code images - values of CPU registers - information regarding its memory space - information regarding its current state

OS is a...

- resource allocator - manages all resources - controls execution of programs to prevent errors and improper use of the computer

How does OS act as a resource manager?

- resources: processor time - goal: run as many processes as quickly as possible

What is system programming?

- writing system calls to access system programs - writing new system programs - enhancing and extending system programs

program counter

-Addresses register (contains addresses of instructions to be fetched) -Single-threaded process has one program counter specifying location of next instruction to execute

Interrupts

-Signals that inform the OS that an event has occurred and is in need of immediate attention -Mechanism by which other modules interrupt normal sequencing of the CPU

Context Switch

-The exchange of register (in the kernel) information occurs when one process is removed from the CPU and another takes its place -System calls results in a context switch from user to kernel mode -set of steps that the kernel takes to switch from one task to another

caching

-copying information into faster storage system -main memory can be viewed as a cache for secondary storage -volatile memory -temporary storage -goal is to reduce time required to fetch data

What is the output of the following C code? printf("%i08", 123456);

12345608

How many different process states are possible?

3 and 5

Multi-core

Allowing CPU to process two or more separate programs at the same time instead of switching back and forth between them

A process that currently waiting on user input is placed in __________ state

Blocked/Waiting

Which of the following statements about the C and C++ programming languages is true? - C++ libraries can be used in C - C++ is backwards compatible with C - Both C and C++ are object-oriented languages - C came after C++

C++ is backwards compatible with C

What is the typical usage of the exec family of system calls?

Enable the child of a fork to run a new program

A process can switch from ready to waiting state (T/F)

False

A process may have multiple parent processes (T/F)

False

All programs that make up an operating system are part of its kernel (T/F)

False

Output devices allow users to send data into the computer. (T/F)

False

Program iterrupts

Generated by some condition that occurs as a result of an instruction execution, such as arithmetic overflow, division by zero, attempt to execute an illegal machine instruction, and reference outside a user's allowed memory space.

Advancements during 1955-1965

Mainframes - Transistors replaced vacuum tubes; smaller, durable, more reliable, less power consumption - Magnetic tapes: a much more efficient way to hold data and code Batch system - can manage multiple jobs - the earliest form of OS

Advancements during 1965-1980

Multiprogramming - Do multiple jobs at once, and share processor while one is waiting for I/O - Access and quick response is lost Timesharing - print to screen instead of paper - multiple terminal interfaces -multiple can have individual access to the processor - get instant results Terminals -keyboards and monitors

What features are shared with C and C++

Preprocessor directives

what does PCB stands for?

Process Control Block - a block of info. that process and tells what operating system will do

What does the PCP contains?

Process state, program counter, CPU registers, CPU scheduling information, memory-management information, accounting information, I/O status

A modern computer consists of

Processor, memory, disks, I/O devices

The name of the register that is responsible for tracking which instruction to execute next is

Program counter

Unit of work within the system (process management)

Program is a passive entity, process is an active entity

Support of modular programming

Programmers should be able to define program modules, and to create, destroy, and alter the size of modules dynamically

Automatic allocation and management

Programs should be dynamically allocated across the memory hierarchy as required. Allocation should be transparent to the programmer. The OS can achieve efficiency by assigning memory to jobs only as needed.

System bus

Provides for communication among processors, main memory, and I/O modules

What is multiprogramming?

Quickly switch multiple processes

What does the kill command do?

Raise a signal to a process

When a processor executes an instruction and produces data, where is it stored first?

Registers

Which of the following forms of data storage are non-volatile? - Registers - Cache - Secondary storage - random access memory

Secondary storage

Protection and access control

Sharing of memory, at any level of the memory hierarchy, creates the potential for one program to address the memory space of another. The OS must allow portions of memory to be accessible in various ways by various users.

Which of the following is NOT a way to create new processes? - Batch jobs - Signals - User request - Process request

Signals

Storage systems organized in hierarchy

Speed Cost Volatility

Process State: Terminated

The process has finished execution; state is being cleared

process state: new

The process is being created

Why might a process voluntarily stop in the middle of its execution?

The process is waiting for data from secondary storage

process state: waiting

The process is waiting for some event to occur

Process State: Ready

The process is waiting to be assigned to a processor

Uniprogramming

The processor spends a certain amount of time executing until it reaches an I/O instruction; it must then wait until that I/O instruction concludes before proceeding

What is the main resources that a process need?

Time on CPU Space in memory

Transition from user to kernel mode

Timer to prevent infinite loop / process hogging resources Timer is set to interrupt the computer after some time period Keep a counter that is decremented by the physical clock. Operating system set the counter (privileged instruction) When counter zero generate an interrupt Set up before scheduling process to regain control or terminate program that exceeds allotted time

Why were batch systems first introduced?

To reduce downtime between jobs

In history of computer technology, which of the following came first? - Integrated circuits - Transistors - Multiprogramming - Timesharing

Transistors

What was developed during 1945-55?

Vacuum tubes

What is a race condition?

When the outcome of programs depends on the scheduler

How to run a specific command from the output of history command?

!number of the command

What character allows you to write commands in multiple lines ?

\

what are the process states?

new, running, waiting, ready, terminated

secondary storage

non-volatile storage capacity Ex: hard disks and solid-state disks

process termination

normal exit (voluntary), error exit (voluntary), fatal error (involuntary), killed by another process (involuntary)

What Happens when we Run a Program?

- Program sits in disk - when executed, copied into memory - processor fetches one machine language instruction at a time from memory

Main memory

- Random access - volatile, lose contents when the power is turned off.

reduced process state diagram

- Running: using the processor at the moment - ready: able to run but waiting for processor time - blocked: unable to run while waiting for external event

Which of the following resources does a process need? - Time with I/O devices - Time with user input - Space on secondary storage - Space on RAM

- Space on RAM

Zombie Process

-A process that has completed execution (terminated) but still has an entry in the process table -If child terminates before parent gets a chance to execute, then the parent can still access the child's data in the Process Table -the entry is removed from the table once the parent reads the info

MBR (Memory Buffer Register)

-A register that holds the data that is being read from or about to be written to the memory

Which pair of methods used to destroy processes are involuntary? - Fatal error and error exit - Fatal error and killed by another process - Killed by another process and error exit - Normal exit and error exit

Fatal error and killed by another process

Which of the following statements about commandline-arguments is true? - Options are always required arguments - Options can be flags - Flags require the - prefix - Flags are always optional arguments

Flags are always optional arguments

What is an advantage of using a computer in the top-down view?

Full understanding of each hardware component is not necessary

System calls vs function calls

Function calls are run in user mode, stay in user space and no special permissions require from OS

hardware failure interrupt

Generated by a failure, such as power failure or memory parity error.

Timer interrupt

Generated by a timer within the processor. This allows the operating system to perform certain functions on a regular basis.

I/O interrupt

Generated by an I/O controller, to signal normal completion of an operation or to signal a variety of error conditions.

context switch

Operating system switch between processes to allow for an interactive system.

Which of the following characteristics is a downside of using system calls? - Access control - Performance - Safety - Application programming interface

Performance

Advancements from 1980-present

Personal Computing

What is the name of the operation that the operating system uses to switch from one job to another ?

context switch

Programs consists of 4 main section in memory :

Text, data, heap, and stack

Process isolation

The OS must prevent independent processes from interfering with each other's memory, both data and instructions

Producer consumer problem: Producer code

while(true){ while(((in + 1) % SIZE) == out) //if buffer is full do nothing buf[in] = next_produced; //place item in buf in = (in + 1) % SIZE //increment buf size }

Producer consumer problem: Consumer code

while(true){ while(in == out) //if buffer is empty do nothing next_consumed = buf[out]; //consume next item from buf out = (out + 1) % SIZE //increment buf size }

Big endian

start with the most significant byte

Little endian

starts with the least significant byte

how to create a new user?

using useradd

What resources does a process need?

Space in memory Time on the CPU

How many modes does vi have?

4 edit, command, visual edit, and extended command mode

what does !! do?

repeat the previous command

OS management responsibilities

- Process isolation - automatic allocation and management - Support of modular programming - protection and access control - long-term storage

Signal: SIGTERM

-Stop the running process -default kill and killall

What are the different types of memory?

1. Main 2. Secondary storage 3. Hard disks 4. Solid-state disks

What is the output of the following C code? printf("%2.2f", 123.456);

123.46

How many byte is 1 word?

4

How to remove a user without deleting their files? rmuser userdel rmuser -k userdel -k

(userdel in incorrect)

What is the difference between Linux and Linux distribution ?

- Linux is open-source software that anyone can use to study, modify, and share. - Linux distribution is an installable operating system that is constructed from a Linux kernel that supports user programs and libraries.

Define the following Terms: static dynamic persistent runtime

- Static contents are unchanged until explicitly edited or configured. - dynamic contents can be changed during active processes. - Persistent contents stay unchanged even after a reboot - Runtime content from a process or from the system is deleted on reboot.

What is the difference between a hard and symbolic link ?

- a hard link is a new directory entry with a reference to an existing file. All files in a system have a hard link by default. - A symbolic link, or soft link, also points to a special file and it can be on a different file system.

process

- a program in execution - an instance of a running program

process termination: normal exit

- exit(): terminate current process, close all file descriptor -return(): only completes current function

What are the two different signal functions in C?

- int kill (pid_t, int sig) : raise a signal - (void) (*signal (int sig, void (*func) (int)) : handle the signals that are caught

Process Creation Step: batch job

- long queue jobs - runs sequentially - on mainframes and server

How to make sure producer and consumer aren't overriding memory?

- make sure in != out (not access same location at same time)

context switch occurs when...

- request service from the operating system - switch from one process to another - interrupts

software interrupt

- software error - request for operation system service - infinite loop

Process Creation Step: user request

- terminal command - GUI interactions

Process Creation Step: system initialization

- when the OS boots up, some processes are automatically created - foreground processes: user interaction - background process (daemons): no user interaction

shared memory

-A space or block that can be written to -treated as an array (consecutive memory locations) -Producer (writes) -Consumer(reads)

Read Block

-Attempt to read from empty block -block until new data available in pipe -if any data becomes available, unblock and read -controls program flow

Write Block

-Attempt to write to a full pipe -block until room for write made available in pipe -unblock only if room available for entire write

Signal: SIGINT

-CTRL + C -Terminal interrupt

Signal: SIGSTP

-CTRL + Z -Terminal stop -Does NOT terminate process -Halts the running process and puts in the background

Signal: SIGQUIT

-CTRL + \ -Terminal quit

Message Passing: Producer - consumer synchronization

-Consumer starts by sending n empty messages to producer so that it waits for empty spaces before starting to produce items -Even if producer produces an item, it will still block until an empty message arrives -When consumer receives an item, it sends the empty space back to producer to allow it to produce more

What kind of hardware interaction requires system calls?

-Create or terminate processes (processor and memory) -User input (keyboard) -Create and delete files (disk)

Process termination (fatal error):

-Process crashes immediately -Safety and security measure -Causes 1. Illegal instruction 2. Reference to nonexistent or disallowed memory addresses

Named Pipes

-FIFO -special file entry in UNIX file systems -persistent (can exist outside of running process) -contain no data (only a point of data exchange) -removed using "rm" like other files - "mkfifo" creates named pipe

MAR (Memory Address Register)

-Holds the address of where data is to be fetched or stored -specifies address in memory for next read/write

Multi-processor

-More than one processor sharing same memory, also known as parallel systems -increased throughput -tightly-coupled -types 1. Asymmetric (each processor assigned to a specific task) 2. Symmetric (each processor performs all tasks)

Unnamed pipes

-No file entry -Transient --destroyed when processes terminate --destroyed when both ends are closed -Unidirectional -accessed only through processes which share same ancestors

Where can signals be sent from?

-OS -Another process -From within a process

Race conditions

-Output depends on sequence and timings of uncontrollable events -processes compete to gain access to resources -processes race to finish their respective instructions without considering where the other is -results are unknown and unreliable -can be solved using synchronization techniques

System call: wait()

-Process waits until one of its children is stopped (terminated or stopped without terminating) -requires <sys/wait.h> -pid_t wait (int * stat_loc) -- pid_t: returns pid of stopped child -- stat_loc: pointer to status macro (info about how child was stopped)

Message Passing Mailbox: Asynchronous communication

-Producer sends messages to consumer, does NOT wiat for empty messages -messages are buffered (sent but not received) -Consumer waits for messages from producer, consumes and then sends an empty message to producer

Process

-Program in execution -Running instance of a program -Entity that can be assigned to and executed on CPU -Single sequential thread execution

Program vs process

-Program is code that can be run; passive entity -Process is a program that is currently running; active entity

Signal

-Simple, pre-defined asynch notification to a running process about a certain event that has occurred -Stop normal flow of process

Multicore

-Use of multiple processors on same chip

Program stack

-assigns a frame to every function in the prog -stack ptr* points to the top function

Message passing

-bidirectional -processes on 2 different machines -used in parallel processing

What all does an instance of a running program contain?

-code image -memory information -current state -value of CPU registers

Pipes

-connect inputs and outputs --redirect output of command or prog from stdout --redirect input of command or prog from stdin --combine the two; output of 1st goes straight to input of 2nd -unidirectional -FIFO

System call: fork()

-creates an exact clone(child) of an existing process(parent) -child gets a copy of the parent's address in a different location -after forking, changes to one address space are not reflected in another; independent processes -return value: 0: if child 1: if parent -1: if unsuccessful -requires <unistd.h> -if you fork n times, you get 2^n processes

Characteristics of secondary storage

-extension of main memory -large, nonvolatile storage capacity

Process Creation Step: system call by another process

-fork()

Signal: SIGHUP

-hang up -gentler termination

Signal: SIGKILL

-hardest termination signal -no custom handler -lacks consideration for memory management and clean up -unsafe

System call: close()

-int close(pipe[file descriptor]) -process closes and relinquishes access to file descriptor -read or write ends are available to both parent and child -close the end that is not being used to avoid race conditions -closing an end in one process does not close it in the other

What are the two different commands to send signals from the Shell?

-kill [options] pid : send signal to process using pid -killall: send signal to all processes with the given namem not pid

Process termination (killed by another process):

-kill() system call -if the process has proper authorization to kill another process then the OS terminates the process

Characteristics of User mode

-limited access -governed by kernel -unprivileged

Characteristics of multiprogramming

-multiple jobs done at once -share CPU while waiting for I/O -con: access and quick response is lost

Characteristics of solid-state disks

-non-volatile -faster than hard disks

System call: read()

-read from read end of pipe -parameters 1. file descriptor (pipe[0]) 2. string (source, where to read from) 3. count (number of bytes to read) -return type: int --number of bytes successfully read -- -1 if unsuccessful

System call: pipe()

-returns 2 new file descriptors in your prog --File descriptors indicate which I/O or resources each process has access to --Each process starts with 3 file descriptors a. 0: stdin b. 1: stdout c. 2: stderr -requires <unistd.h> -Parameters: int pipefd[2] ( [0] is read end, [1] is write end) -return type: int (0 if successful else -1)

Characteristics of hard disks

-rigid metal/glass platters covered with magnetic recording material -virtual memory -extension to main memory

rendezvous or "run in lockstep"

-send needs to be executed before receive -send will block till receive is executed -if receive executed first, block till send is executed

Message passing primitives

-send(destination, &message) -receive(source, &message)

Characteristics of main memory

-volatile -principal internal memory system -random access -each location has a unique address

System call: write()

-write to a pipe from write end -parameters 1. file descriptor (pipe[1]) 2. string (destination, where to write) 3. count (number of bytes to write) - return type: int -- number of bytes successfully written -- -1 if unsuccesfful

steps in making a system call

1-3. push number of bytes, location save the bytes from the read command, file to read from 4. The Actual procedure call / System call Library interface 5. Library will put the code/System call number for this system call into the appropriate register 6. Library executes a Trap instruction. - Trap is an instruction that signals the OS to switch from User space into Kernel space 7. OS Kernel starts by examining the registers and determine what, who called the trap and dispatch the request to the system call handler 8. OS perform the requested System call 9. Return the results to user space mode 10. return results to user program 11. user program receive results and clean up the stack

Process states

1. New - process is being created 2. Ready - waiting to be assigned to a processor 3. Waiting - waiting for an event to occur 4. Running - instructions are being executed 5. Terminated - process finished execution

Process in memory consists of....

1. Stack (temp data - local variables, function parameters, return addresses) 2. Heap (dynamic allocation - malloc) 3. Data (global variables) 4. Text (code)

Types of message passing:

1. Synch -sender and receiver have to wait for each other 2. Asynch -Underlying system buffers the message so that sender and receiver don't have to wait for each other

Process Creation Steps

1. System initialization 2. system call by another process 3. user request 4. batch job

Shared memory buffer types

1. Unbounded (no limit on size) -Producer can always place new item into before without having to wait -Consumer may have to wait for producer to produce 2. Bounded (limited size) -Producer waits if buffer is full -Consumer waits if buffer is empty

Types of Pipes

1. Unnamed pipes in C 2. Unnamed pipes in Shell 3. Named pipes in UNIX file systems "mkfifo"

Historical timeline of OS

1. Vacuum Tubes 2. Mainframes 3. Batch systems 4. Multiprogramming 5. Timesharing 6. Terminals 7. PC

POSIX Shared memory steps:

1. define and create shm object using shm_open() system call 2. Allocate size for memory 3. Map the memory to process 4. Unlink the memory when done

In which order should the following system calls be performed? pipe() fork()

1. pipe() 2. fork() Always pipe before forking so that both parent and children have access to the pipe

How many types of special permissions in Linux file system?

3

how many levels of caches in modern CPUs?

3

Which man section is dedicated to Games?

6

How many bit is in 1 byte?

8

Interrupt Vector

Address where the CPU starts executing to service an interrupt

What if producer is much faster than consumer?

All message spaces will end up being used and producer will block until an empty message arrives

What is the function of the system bus?

All the components of a modern computer (Processor, Memory, I/O, supporting) communicate with each other through the system bus

What is the earliest form of OS?

Batch systems

What if consumer is much faster than producer?

Consumer will block; waiting for producer to send a message

A Terminal and a Shell are the same thing (T/F)

False

Process State: Running

Instructions are being executed

system calls

Instructions that interrupts the program being executed and requests a service from the operating system.

POSIX

Portable OS Interface

PCB stands for

Process Control Block

Process termination (error exit):

Process completes and terminates but produces incorrect results

Which processes can use the pipe?

Process that calls pipe() and any of its children

What is the fastest IPC technique?

Shared Memory

What is multiplexing? What are the two types?

Sharing resources seamlessly -Time multiplexing: sharing time of use of Processor, I/O etc - Space multiplexing: sharing space on memory, disk

How can two processes communicate with each other?

Using Inter-Process Communication (IPC) techniques

How do the producer and consumer access the shared memory buffer?

Using a (void) ptr*

How can we do IPC between different processes on 2 different machines?

Using message passing

How does a process get created or terminated?

Using system calls

How to know how many hard links attached to a file in Linux?

We can find the number of hard links attached to a file in Linux by using the ls -l command. One of the items it reports is each file's link count i.e. number of hard links that file has.

Would you be able to redirect an output of a command to a file AND print the same output to a screen?

Yes, using | and tee

What is the default shell in RHEL?

bash

How to print the value of a variable named "Var" in shell ?

echo $Var

How to declare variable named "VAR" in a shell?

export

System calls vs. function calls

function calls - functions that can run in user mode (stays in user space) - does not need special permissions from the OS System calls - processes in user space do not have access to some instructions - must make a request to the OS, which will run those instructions on the behalf of the user mode process - context switching == expensive

What does ' . ' mean in Linux file systems?

indicate a hidden file and point to current directory

How do you view the Linux filesystem hierarchy?

inverted tree

What happens if you copy a file with to a location with a file with same name?

it will overwrite it

How to view hidden files and folders?

ls -a

How do you search the man pages titles ?

man -s command

To know how long a system been running, you can use the command ...

ps

How to know where you are located in the hierarchy of file systems?

pwd

What does "2>" do ?

redirect error

What command to use to interactively monitor system processes?

top

How does Linux differentiate between Users?

using UID

How to create a new user?

using useradd

What is the output of the following C code? printf("%d", printf("asd")); - %dasd - asdasd - asd%d - asd3

asd3

How Does a Process gets created or terminated in the OS?

by using system calls

What do you think The OS needs to save before switching from one process to the next ?

data

Asymetric Multiprocessing

each processor is assigned a specific task

Symmetric Multiprocessing

each processor performs al tasks

interrupt driven

hardware interrupt by one of the devices

big/little endian

important if the programmer needs to check or perform operations on individual bytes or when transferring binary data from two different computers architectures.

"The one program running at all times on the computer"

kernel

Which of the following shell commands does NOT provide information about processes? - pstree - cp - ps - top

ps

Storage-Device Hierarchy

registers cache main memory solid-state disk hard disk optical disk magnetic tapes

Trap/Exception

software-generated interrupt caused either by an error or a user request

Execution Context (Process State)

the internal data by which the OS is able to supervise and control the process

What is the benefit of properly scheduling processes?

It prioritizes more important processes

What happens to a process after it successfully calls fork()?

It resumes execution

How is the main memory storage view as?

a 1-dimensional array of words


Conjuntos de estudio relacionados

Davis Pediatric Success Chapter 5 Cardiovascular Disorders

View Set

Master Gunner ™ Bradley: Ammo Capabilities

View Set

Stage 1 Biology: Multicellular Organisms

View Set

MGT 305 exam 2 Practice Homework

View Set

AP Human Geography Folk and Pop Culture vocab

View Set