Operating Systems Test 1

5.0(1)
studied byStudied by 11 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/65

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

66 Terms

1
New cards

One of the roles of an operating system is that of a "glue". From the list below please select all examples of an OS acting as "glue"

-Files created by one application can be opened by another application
-Different apps have the same set of services, for example, the cope-paste function

2
New cards

One of the roles of an operating system is that of a "referee". From the list below please select all example of an OS acting as a "referee"

-Allocate resources for users and applications
-Provide an execution environment with common set of services

3
New cards

One of the roles of an OS is to act as an "illusionist". It makes your computer appear more

powerful

4
New cards

What memory regions do threads share within the same process?

data, instruction, heap. NOT stack, stack is divided among threads

5
New cards

T/F Threads are more expensive for the operating system kernel to create than processes

False

6
New cards

T/F An operating system should never create more processes than the available number of processors

False

7
New cards

T/F Linux is an example of a monolithic kernel

True

8
New cards

T/F The interrupt vector table should be held in kernel memory and not arbitrarily changed by users

True

9
New cards

T/F A command interpreter on the Linux system is also known as a shell

True

10
New cards

T/F fork() in Linux creates a child process, which then executes the function that is passed as an argument

False

11
New cards

T/F When you are programming with Posix pthreads there are several different exec() calls with different arguments

True

12
New cards

T/F Dana makes 8 calls to fork() in main. This is called a fork bomb.

False

13
New cards

T/F Threads created by a single process share the same memory address space

True

14
New cards

What piece of code goes on the line below?

check test

15
New cards

How many processes will be created in the code below?

main(){

fork()
fork()
fork()
fork()
fork()
print(hello world)

return 0
}

32, aka 2^5

16
New cards

What is the output of the following code segment below?

main(){
pid = fork()
if(pid == 0){
print statement 1
}else{
print statement 2
}
wait()
return 0
}

both statement 1 and statement 2 are printed

17
New cards

In the code segment below, what is printed on line 12?

check test

18
New cards

An operating system running in a virtual machine

guest OS

19
New cards

A kernel procedure invoked when an interrupt occurs

interrupt handler

20
New cards

Instruction available in kernel mode but not in user mode

privileged instruction

21
New cards

A hardware device that can cause a processor interrupt after some delay

hardware timer

22
New cards

The set of threads that are ready to be run

ready list

23
New cards

An operating system that provides the abstraction of a virtual machine, to run another operating system as an application

host OS

24
New cards

A software interrupt is also called

synchronous

25
New cards

A signal to the processor indicating an event needs immediate attention

interrupt

26
New cards

An interface between user process and OS is called

system call

27
New cards

Processor register points to the kernel memory area

interrupt vector table (IVT)

28
New cards

Returns child id to the reaping parent

wait()

29
New cards

Multiple activities happen at the same time

concurrency

30
New cards

Data structure that lives in kernel memory and contains thread specific information

thread control block (TCB)

31
New cards

Synchronization variable used by only one thread at a time

lock

32
New cards

Allow waiting inside a critical section

condition variables

33
New cards

When doing Posix pthread programming you need to include

pthread.h header file

34
New cards

Producer-consumer is an example of

one-way communication

35
New cards

Which one has an associated control block?
-process
-thread
-none
-both

both

36
New cards

Which one has a unique id?
-process
-thread
-none
-both

both

37
New cards

An operating system has two modes - user mode and kernel mode. Please select all true statements from the list below

-kernel is a fully trusted "central" part of an OS and has access to all the hardware
-process in user mode can request kernel to act on its behalf by making a system call
-mode bit in PSR can be only changed by kernel
-kernel mode allows to access any I/O device
-kernel mode allows process to execute with full privileges on the system's hardware

38
New cards

T/F All of the following are examples of system calls: fork(), read(), mkdir(), getpid(), open(), close(), and wait().

True

39
New cards

________ is software to manage computer resources for its users and applications that can often contain millions of lines of code.

operating system

40
New cards

T/F Concepts learned in the OS course will be applicable to many different fields of study within computer science and even other disciplines.

True

41
New cards

Three roles of an OS

illusionist, referee, glue

42
New cards

Difference between program and process

A program is an executable image that has both instructions and static data (initial values). A process is an instance of a program, running with limited rights

43
New cards

Memory areas of executable image =

data and instructions

44
New cards

What goes on heap and stack

shared objects (global variables(static), dynamically allocated objects) are on the heap, stack has local variables.

The heap memory is used for storing objects and data structures that require a longer lifespan than stack memory.

Each thread gets a stack, while there's typically only one heap for the application.

45
New cards

Difference between process and thread

processes and threads share a heap, data, and instructions
threads do not share a stack with process

46
New cards

how are processes identified

pid, an integer

47
New cards

how are threads identified

tid, long integer

48
New cards

How are process ids assigned?

assigned by system in order they are created

49
New cards

what is in 'proc' directory?

a folder for every running process

50
New cards

what does 'top' command do?

used to see all running processes and "demons"

51
New cards

what does 'htop' command do?

shows the same thing as 'top' command but color coded and 'ps' shows snapshot of processes (not live updated)

52
New cards

What is a kernel?

lowest level of OS software, it allows access to hardware in a controlled way via system calls

53
New cards

What does it mean that kernel is "interrupt driven"?

software and hardware can be interrupted anytime, interrupt is usually the switch between user mode and kernel mode

54
New cards

What receives an interrupt signal?

processor

55
New cards

What are the two kinds of interrupts?

software/synchronous and hardware/asynchronous
...why called that?

56
New cards

What will an interrupt execute?

an interrupt service routine or a handler

57
New cards

The interrupt vector table should be...

held in kernel memory and not arbitrarily changed by users

58
New cards

Can we overwrite interrupt handlers?

We can overwrite interrupt handlers from the table by writing our own signal handlers (use 'signal' call), signal call does not send a signal but just tells kernel what ISR to execute

59
New cards

What type of kernel does Linux have?

monolithic

60
New cards

Monolithic kernel

A monolithic kernel is an operating system architecture where the entire system runs in kernel mode. In this design, the kernel consists of a single, large executable that includes various services such as memory management, device drivers, file system management, and process management, among others.

61
New cards

Micro kernel

A microkernel is a type of operating system kernel that is designed to provide only the most basic services required for an operating system to function, such as memory management and process scheduling. Other services, such as device drivers and file systems, are implemented as user-level processes that communicate with the microkernel via message passing. This design allows the operating system to be more modular and flexible than traditional monolithic kernels, which implement all operating system services in kernel space.

62
New cards

Posix threads

POSIX - Portable Operating System Interface for Unix (defined in IEEE standard)
-It is a language-independent execution model using pthreads (POSIX threads) with >100 procedures for
--Thread creation/joining
--mutual exclusion
--condition variables
--synchronization

63
New cards

What is a fork bomb?

Program which harms a system by making it run out of memory (basically called fork too many times). A form of denial-of-service (DoS) attack against a Linux/Unix based system. The only solution to a fork bomb is to destroy all instances of it.

64
New cards

What is a condition variable?

Synchronization object that allows a thread to efficiently wait for a change in shared object that is protected by a lock.
-Called only when holding a lock
-Ex.: Wait until queue is non-empty to remove item instead of returning an error

Condition variables are synchronization primitives that enable threads to wait until a particular condition occurs. Condition variables are user-mode objects that cannot be shared across processes. Condition variables enable threads to atomically release a lock and enter the sleeping state.

65
New cards

What is a lock?

a primitive (synchronization variable stored in memory) that only one thread at a time can use.

66
New cards

Name several system calls

fork(), read(), mkdir(), getpid(), open(), close(), wait()