Operating Systems Flashcards

1
Q

What is a program?

A

Compiled code that can run on the OS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a task in OS and microcontrollers?

A

Basic unit of programming which an OS controls. Depending on the OS, a task may be each program or each process within a program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a thread?

A

Basic unit of CPU utilization. At most basic consists of a program counter, stack, set of registers and a thread id.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a context switch in OS?

A

Act of storing the state of a thread or process, so said thread or process can be resumed at a later date.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is pre-emptive multitasking?

A

The use of interrupts and a scheduler to determine which process should execute next. It is a common multitasking technique, where the OS allocates different amounts of time for a process based on its priority.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is cooperative multitasking?

A

Also non as non-preemptive multitasking at times.the OS provides the appearance of simultaneous execution by rapidly switching between tasks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is blocking in operating systems?

A

Blocking refers to processes that are waiting for a specific event or resources to become available. These processes are timeout protected.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Define priority in Operating systems

A

The level of importance of a task. Multiple tasks can have the same priority.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a scheduler in operating systems?

A

A scheduler is a software that handles task scheduling. i.e. the order in which tasks are exectuted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Define Timers in Operating Systems

A

The main task of a timer is to interrupt the CPU after a specific period of time. Used to generate ticks at precise intervals. Must count continuously.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define Interrupts in Operating Systems

A

Signals sent to the CPU to stop the current task and to accordingly create an alternate portion of the OS to deal with the signal.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an operating system?

A

Software that manages computer hardware resources

It is used to provide common services for programs,

Many applications cannot run without it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Describe the system hierarchy

A

At the top of the hierarchy is the user who only interacts with the application. The application interacts with the OS and user but does not interact with the hardware. The OS interacts with the application and the Hardware. The Hardware only interacts with the OS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the common types of Operating System?

A

Multi-user

Multi-tasking

Distributed

Embedded

Templated

Real Time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Features of a multi-user operating system

A

Multiple Users can share the same system, used by time-sharing systems/servers. For each user appears as if they have sole control over the system.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Features of a Multi-tasking Operating System

A

Allows multiple programs to execute simultaneously

Uses pre-emptive or cooperative multitasking

Has Slotted behaviour

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Features of a Distributed Operating System

A

Allows for management of a group of computers as one

Can spread distributed computations across multiple machines

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Features of a Templated Operating System

A

Single ‘virtual machine’ acts as a guest of the operating system

Used in virtualisation and cloud computing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Features of an Embedded Operating System

A

Used on embedded computer systems

Can operate with limited resources

Compact and efficiency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Features of a Real-Time Operating System

A

Specialised scheduling algorithms

Deterministic behaviour

Quick, predictable response to events

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is the kernel?

A

The lowest level of the operating system

Manages I/O requests from software

Translates them into data processing instructions for the CPU/other components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What is the difference between kernel mode and user mode programs?

A

Kernel Mode has access to each resource in the operating system

User-mode programs are in turn restricted in their access

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Differences betwen Kernel Mode and User Mode drivers

A

In kernel mode, the lack of restrictions means the driver may overwrite resources used by other programs.

However, with user-mode programs, this cannot happen.

User-mode drivers allow for immediate restarts of the driver when required, not possible with kernel mode drivers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Define the Operating System Shell

A

This is the user interface for an operating system, it is often graphical and is a task in itself.It interfaces with the kernel.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

What are some of the common features of Modern Desktop Operating Systems

A

Modern Operating Systems are more reliable, this is because ‘unreliable’ interfaces can run in user mode and normally implement preemptive multitasking.

Rare Failures for modern systems are:

Hardware Failure

CPU stuck in device driver

Fatal exception in device driver/kernel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What is virtual memory?

A

Virtual memory can be defined as a technique that uses main memory as a ‘cache’ for secondary storage.

Or a feature of an OS, which allows the system to compensate for shortages in physical memory by temporarily transferring pages of data from RAM to disk storage.

It allows a program to access memory via a virtual address

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

What are the benefits of a ‘virtual’ address?

A

A virtual address can be translated into a physical address and is used to access main memory.

It allows for efficient sharing of memory between programs, although one must keep in mind how this is structured.

It removes the programming burdens of limited memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is a page

A

A page is a contiguous block of virtual memory,

contiguous meaning solid block of data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is a page fault

A

A page fault is when an accessed page is not found in the main memory.

This means the page must be retrieved from the disk which is more than 1000x slower than retrieving from main memory. This severely slows down program execution speed.

30
Q

What is a super loop/embedded loop?

A

A super loop is an alternative to OS. It is simply a loop in which other tasks are run. The loop is not meant to end.

31
Q

Features of Super loops

A

Simple, easy to build, debug, test and maintain

Efficient as minimal hardware requirement

Highly portable, can easily be implemented on many kinds of devices.

However, Not accurate/ flexible enough for precision timing.

Operates at full power at all times, the device never sleeps.

32
Q

How can programs be designed for time-constraints

A

Delays can be used to run a program at specific times, however, this approach is flawed as it requires precise knowledge of how long a task takes and for said task o never vary in execution time.

Alternatively, hardware timers can be used to generate interrupts. As long as the timer counts continuously the program can be designed to generate ticks at precise intervals.

33
Q

For timers, what is a tick?

A

A tick is an arbitrary unit for measuring internal system time. What exactly is a tick varies based on the OS and may vary by installation.

-Super User

34
Q

What does the rate of tick generation depend on?

A

The rate of tick generation depends on the crystal frequency and the counter configuration

35
Q

How can software reduce power consumption?

A

This can be achieved by putting the system to a kind of sleep. Here interrupts can be used to wake the system up at next processor overflow.

36
Q

What states can tasks be in?

A

Running- actually using the processor

Ready- Able to run but a higher priority task is currently running

Blocked- waiting for an external event or time, but is timeout protected

Suspended - Not available for scheduling and is not timeout protected

37
Q

How does multitasking support the OS?

A

Multitasking and intertask communication allow for complex applications to be partitioned into smaller, more manageable tasks.

This makes software testing easier as well as work breakdown between teams and code reuse.

It means that timing and sequencing details can be removed from the application code and laid into the hands of the OS.

38
Q

Why use context switching

A

Context switching is used as tasks do not have an awareness of when they are suspended, so the OS saves the context of the system to be restored via the kernel near execution time. This increases performance as it means that higher priority tasks can be run when ready and allow for scheduling.

39
Q

What is a scheduling policy?

A

It is an algorithm that a scheduler uses to determine which task to execute at a particular time

40
Q

What are the benefits of RTOS?

A

Task Scheduling: Tasks are called when needed, ensuring better program flow and event response times

Multitasking:. Task scheduling gives the illusion of multiple simultaneous task executions

Deterministic Behaviour: Events and interrupts led are handled within a defined time

Shorter ISRs: enables more deterministic interrupt behaviour

InterTask Communication: manages sharing of data, memory and hardware resources between multiple tasks

System Management: Allows focusing on app development rather than resource management

Defined Stack Usage: Each task has a defined stack space allowing for predictable memory usage.

41
Q

What are the limitations of RTOSs?

A

Unlike desktop Os, programs cannot be loaded after compilation or easily exchange components.

The entire system must be completed together at compile-time, whilst this is efficient as optimisation is applied on the entire program, this is also restrictive as any changes require a firmware update.

42
Q

What are the RTOS timing categories?

A

Strict Timing: Events must happen on a strict schedule e.g. every 10ms

Flexible timing: Wide range of acceptable times

Deadline only timing:Only Upper Limit is specified

43
Q

What is the RTOS scheduling policy?

A

Ensure that the highest priority task that is able to execute is the task given processing time.

44
Q

Results of the RTOS scheduling policy

A

This means processing time may have to be shared, ‘fairly’ between tasks of equal priority if the tasks are able to run simultaneously.

45
Q

What are the features of a sleeping task and a blocked task in RTOS?

A

When sleeping the task specifies the wake time

When blocked, the task specifies the maximum wait time.

46
Q

How does the RTOS measure time?

A

The RTOS measures time using a tick ‘count’ variable, a tick is implemented using timer interrupts, the resolution of a tick is dependent on the interrupt frequency.

At each tick the kernel checks whether to unblock/wake tasks

47
Q

For RTOS, what happens when tasks are sleeping

A

When sleeping a task gives up its access to the CPU. It specifies its wake time.

48
Q

For RTOS, what happens when tasks are blocked?

A

When blocked a task specifies its maximum wait time.

49
Q

Describe Task Priority

A

Each task as a priority

The idle task has a priority of zero

Low priority numbers are for low priority tasks

50
Q

What is the relationship between tasks and the scheduler?

A

Tasks have no knowledge of the scheduler

Whilst the scheduler’s job is to ensure the context around a task is saved whilst the task may be blocked, suspended etc.

51
Q

What are the benefits and flaws due to separate stacks for each task?

A

Benefits: Simple, no restriction on use, supports full preemption, fully prioritised

Flaws: High usage from individual stacks, restrictions on re-entrancy are required, i.e. on subroutines calling themselves.

52
Q

Describe the Idle Task

A

The Idle task runs at lowest priority, it is used to clean up resources allocated by the kernel to deleted tasks

It can call a ‘hook’ function when no higher priority tasks are available

Hook function puts the processor into low power mode

53
Q

Steps for RTOS context switch

A
  1. TaskA is executing, TaskB previously suspended, so context already saved on TaskB stack.
  2. RTOS ‘tick’ occurs as TaskA is about to execute LDI. When tick occurs, places PC on stack before jumping to the RTOS tick ISR
  3. To save context, pushes context of processor onto TaskA stack. Kernel stores copy of stack pointer for each task
  4. After context has been saved, increments tick count.
    In this example, incremented tick count means that TaskB is now ready to run.
    TaskB has a higher priority than TaskA, so kernel selects TaskB to be given processor time.
  5. Task B stack pointer is
    retrieved.
  6. Restores TaskB context from the stack into the processor registers
  7. The stack pointer was adjusted to point to TaskB’s stack, Program Counter restored for TaskB.
    So, when e.g. returning from interrupt, executes next TaskB instruction
54
Q

What is free RTOS?

A

Ported to at least 34 Processors

Open Source free software for rtos system

55
Q

Features of RTLinux

A

Linux kernel operates as a thread

Interrupts for deterministic processing are processed by the real-time core; other
interrupts forwarded to Linux (running at a lower priority)

Linux drivers handle general I/O

Can use FIFO to transfer between OS and RTLinux

Example capabilities (on x86 hardware):

15 µs to begin an ISR after an interrupt event

Periodic tasks run within 25 µs of schedule

Compared against ‘standard’ Linux
Up to millisecond level scheduling precision
•Not designed for guaranteed timing

56
Q

WHat is RTLinux

A

RTLinux : modified Linux kernel
Adds hard real time capabilities to ‘standard’ Linux OS
Runs whole Linux OS as fully pre emptive process
Can use for real time control
Capability of running real time tasks and interrupt handlers: execute regardless of
Linux OS operations
http://

57
Q

Linux Kernel Vs RTLinux Kernel

A

Linux drivers handle general I/O
Can use FIFO to transfer between OS and RTLinux
Example capabilities (on x86 hardware):
15 µs to begin an ISR after an interrupt event
Periodic tasks run within 25 µs of schedule
Compared against ‘standard’ Linux
Up to millisecond level scheduling precision
Not designed for guaranteed timing

58
Q

Describe the operation of RTLinux

A

Linux kernel operates as a thread
Interrupts for deterministic processing are processed by the real time core; other
interrupts forwarded to Linux (running at a lower priority)

59
Q

How are periodic tasks implemented via timer interrupts

A

The timed interrupt is declared early on in the program. The task is executed using functions called from the ISR

60
Q

What does ISR stand for?

A

Interrupt Service Routine

61
Q

What is strict timing

A

Events must happen on a strict schedule e.g. every 15ms.

62
Q

What is flexible Timing

A

Events have a wide range of Acceptable times

63
Q

What is deadline only timing?

A

Only the upper limit of event duration is specified.

64
Q

RTOS Context Switch Step One

A

TaskA is executing
TaskB previously suspended, so context already saved on TaskB stack

65
Q

RTOS Context Switch Step Two

A

RTOS ‘tick’ occurs as TaskA is about to execute LDI
When tick occurs, places PC on stack before jumping to the RTOS tick ISR

66
Q

RTOS Context Switch Three

A

To save context,
pushes context of
processor onto TaskA
stack
Kernel stores copy of
stack pointer for each
task

67
Q

RTOS Context Switch Step 4

A

After context has been saved, increments tick count
In this example, incremented tick count means that TaskB is now ready to run
TaskB has higher priority than TaskA , so kernel selects TaskB to be given
processor time

68
Q

RTOS Context Switch Step 5

A

Task B stack pointer is
retrieved

69
Q

RTOS Context Switch Step 6

A

Restores TaskB context from the stack into the processor registers

70
Q

RTOS Context Switch Step Seven

A

Stack pointer was adjusted to point to TaskB’s stack, Program Counter restored for TaskB
So, when e.g. returning from the interrupt, executes next TaskB instruction