Assignments Flashcards

1
Q

What are the three primary reasons for an Operating System?

A

Manage hardware and resources, Provide a user interface, Run and manage applications

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

privileged instructions

A
  • switch from user to kernel mode
  • set the value of a timer
  • clear memory
  • turn off interrupts
  • modify entries in a device status table
  • Access I/0 device
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give two reasons why caches are useful

A

-Caches are useful when two or more components need to exchange data, and the components perform transfers at differing speeds.
-A cache allows a device to run faster.

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

In order for a cache to be useful, cache _________ must be ensured so that every copy of the datum has a valid up-to-date value.

A

coherency

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

Rank the following storage systems fromslowesttofastest

A
  1. magnetic tapes
  2. optical disk
  3. hard drive disk
  4. nonvolitile memory
  5. main memory
  6. cache
  7. registers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the purpose of interrupts

A

to change the sequence of instructions executed on the processor.

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

Direct Memory Access (DMA) is used to offload the CPU when transferring data to and from high-speed I/O devices. How does the CPU coordinate with the device to initiate a DMA transfer?

A
  • The CPU writes values such as the memory address, byte count, and transfer direction into special registers accessible by the DMA controller
  • The CPU initiates the transfer, and the DMA controller manages the actual data transfer without requiring the CPU’s involvement.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does an interrupt differ from a trap?

A
  • interrupts are asynchronous, meaning they can occur at any time, while traps are synchronous and occur during the execution of specific instructions.
  • An interrupt is triggered by external hardware events, while a trap is generated by a software or internal event.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are some key challenges in designing operating systems for mobile devices compared to designing operating systems for traditional PCs?

A
  • Mobile operating systems need to accommodate a wide variety of sensor inputs (such as GPS, accelerometers, and touchscreens) not typically found on traditional PCs.
  • Mobile operating systems need to manage more constrained resources, such as battery life, memory, and processing power, compared to traditional PCs.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Match the arguments with whether they support or oppose including applications such as web browsers and mail programs in the operating system.

A

-Bundling applications ensures better integration with the OS : In favor
- Reduces flexibility and user choice: Opposed
- Simplifies installation and maintenance for users. In Favor
- Can lead to unfair competition for third-party developers: Opposed
- Increases the OS size and complexity, potentially reducing performance: Opposed
- Provides users with essential tools out of the box: In favor

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

How do clustered systems differ from multiprocessor systems?

A

Clustered systems are designed primarily for increasing reliability and scalability, whereas multiprocessor systems are primarily used to enhance processing power and performance through parallel processing.
- Clustered systems consist of multiple independent computers (nodes) connected via a network, while multiprocessor systems use multiple CPUs within a single computer sharing the same physical resources like memory and storage.
- In clustered systems, each node operates independently with its own resources, while in multiprocessor systems, CPUs share memory and input/output devices.

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

What is required for two machines in a cluster to cooperate in providing a highly available service?

A

-A shared storage system or data replication must be implemented to ensure that both machines have access to the same data and can continue functioning if one fails.
- There must be a mechanism for detecting failures and automatically transferring services from the failed machine to the operational one to maintain availability.

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

How does a trap to the operating system interact with the CPU’s bit mode, and what role does bit mode play in handling such traps?

A

A trap, which is a type of synchronous interrupt triggered by an exceptional condition or system call, is handled differently based on the CPU’s bit mode, where user mode and kernel mode operations are distinguished by the bit mode settings.

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

The services and functions provided by an operating system can be divided into two main categories. Which of the following correctly describes these two categories and explains how they differ?

A

User Services vs. Kernel Services:
User services provide functionalities like file management and user interfaces, while kernel services manage hardware resources such as CPU scheduling and memory management.

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

Operating systems use different methods for passing parameters during system calls. Which of the following are valid methods for passing parameters to the operating system?

A

Pass Parameters in Registers:
The parameters are stored in CPU registers, and the operating system retrieves them directly during the system call
- Pass Parameters on the Stack:
Parameters are pushed onto the system stack, and the operating system pops them off to retrieve the necessary data during the system call.
- Pass Parameters Using Memory Block:
The parameters are stored in a block of memory, and the address of this block is passed to the operating system. The OS accesses the block to retrieve the parameters.

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

Which of the following methods can be used to obtain a statistical profile of the amount of time a program spends executing different sections of its code?

A

Utilizing a profiler tool to measure the time spent in each section of the code.

17
Q

Why does Android use ahead-of-time (AOT) compilation rather than just-in-time (JIT) compilation? Select all that apply.

A
  • Ensures code optimization and consistency across different devices.
  • Improved performance by translating the entire application code into native machine code before execution.
  • Enhances security by reducing the attack surface.
  • Better battery efficiency as AOT compilation consumes less power compared to JIT.
  • Reduced startup time since the code is already compiled.
18
Q

What are the two models of interprocess communication? Select all that apply.

A
  • Message Passing
  • Shared Memory
19
Q

Contrast and compare an application programming interface (API) and an application binary interface (ABI). Select all that apply.

A

-An ABI defines the low-level binary interface between two program modules, often between an operating system and user programs.
- An API includes function signatures, return types, and parameter types, but does not specify how these are implemented at the binary level.
- An ABI includes details such as calling conventions, machine instruction sets, and binary formats, which are crucial for runtime execution.
- An ABI is concerned with binary compatibility, ensuring compiled programs can work together without recompilation.
- An API defines the methods and data structures developers use to interact with software components.
- An API is concerned with source code compatibility, ensuring that different software components can work together at the source code level.

20
Q

What is the main advantage of the microkernel approach to system design?

A

Enhanced security and stability by isolating critical services in user space.

21
Q

What are the advantages of using loadable kernel modules? Select all that apply.

A
  • They reduce the overall size of the kernel by loading modules only when needed.
  • They enable the kernel to be extended without rebooting the system.
22
Q

Why do Java programs running on Android systems not use the standard Java API and virtual machine? Select all that apply.

A
  • Android uses a different set of APIs optimized for mobile devices.|
  • Licensing issues prevent the use of the standard Java API and virtual machine on Android.
  • The standard Java API and virtual machine are not designed for the constraints of mobile environments.
  • Android’s Dalvik and ART runtimes are optimized for performance and memory usage on mobile devices.
23
Q

When a process creates a new process using thefork()operation, which of the following states is shared between the parent and child processes?

A

Shared memory segment

24
Q

include <sys/types.h>

Using the program shown below,

#include <stdio.h>
#include <unistd.h></unistd.h></stdio.h>

int value = 8;

int main()
{
pid_t pid;

pid = fork();

if (pid == 0) { /* child process /
value += 15;
return 0;
}
else if (pid > 0) { /
parent process /
wait(NULL);
printf(“PARENT:value = %d”,value); /
LINE A */
return 0;
}
}
The output after the code atLINE Aexecutes is ________________.

A

8

25
Q

include <stdio.h></stdio.h>

#include <unistd.h></unistd.h>

int main()
{

fork();

fork();

fork();

fork();

}

Including the initial parent process, the number of processes that are created by the program shown above is ________________.

A

16

26
Q

include <sys/types.h>

Using the program in the figure below,

#include <stdio.h>
#include <unistd.h></unistd.h></stdio.h>

int main()
{
pid_t pid, pid1;

/* fork a child process */
pid = fork();

if (pid < 0) { /* error occurred /
fprintf(stderr,”Fork Failed”);
return1;
}
else if (pid == 0) { /
child process /
pid1= getpid();
printf(“child:pid = %d”,pid); /
A /
printf(“child:pid1 = %d”,pid1); /
B /
}
else { /
parent process /
pid1= getpid();
printf(“parent:pid = %d”,pid); /
C /
printf(“parent:pid1 = %d”,pid1); /
D */
wait(NULL);
}
return 0;
}

Assume that the actual pids of the parent and child are2600and2603, respectively.
The value of pid at line A is?
- The value of pid1 at line B is?
- The value of pid at line C is?
- The value of pid1 at line D is?

A
  • The value of pid at line A is0
  • The value of pid1 at line B is2603
  • The value of pid at line C is2603
  • The value of pid1 at line D is2600
27
Q

What are the purposes of system calls? (Select all that apply)

A

-To enable user programs to request services from the operating system, such as file operations or process control.|
- To ensure secure communication between hardware and software.
- To provide an interface between user programs and the operating system.
- To allow direct hardware manipulation by user programs.

28
Q

Which system calls must be executed by a command interpreter or shell to start a new process on a UNIX/Linux system? (Select all that apply)

A
  • forck()
  • excec()
  • wait()
29
Q

Some computer systems provide multiple register sets. Consider the case where processes A and B contexts are loaded in the register sets. What happens during a context switch when process C is next in line to execute, assuming process C’s context is in memory and all the register sets are in use? (Select all that apply).

A
  • The CPU current-register-set pointer is changed to point to the set that will be replaced, either process A or B.
  • Process A or B may resume execution when its context is reloaded into a register set after process C finishes.
  • The context pointed to by the current-register-set pointer is moved to memory, and process C’s context is loaded from memory into the set.
  • Process C’s context will be directly loaded into a register set without saving any other process context.
30
Q

include <sys/types.h>

Under what circumstances will the line of code markedprintf("LINE J")in the code below be reached?

#include <stdio.h>
#include <unistd.h></unistd.h></stdio.h>

int main()
{
pid_t pid;

/* fork a child process */
pid = fork();

if (pid < 0) { /* error occurred */
fprintf(stderr,”Fork Failed”);
return1;
}
else if (pid == 0) {
execlp(“/bin/ls”,”ls”,NULL);
printf(“LINEJ”);
}
else {
wait(NULL);
printf(“Done”);
}

return 0;
}

A

LINE Jwill be printed if theexeclp()system call fails.

31
Q

In which situations are ordinary pipes more suitable than named pipes? (Select all that apply)

A
  • When communication is required between two processes running on the same machine that have a parent-child relationship.
  • When communication is required between a parent and child process in the same program.
  • When you need a simple and temporary communication method between related processes.