Introduction to Operating Systems Flashcards
What are the two main functions of an OS?
To interact with the hardware and to interact with the user
Why are instructions related to I/O devices typically privileged instructions? (can be executed in kernel mode but not in user mode)
Restriction is in place for security and protection purposes
What is the difference between Kernel and User Mode?
Kernel mode, the CPU has unrestricted access to system resources and can execute privileged instructions; User mode, access is restricted and certain operations are prohibited
How does having two distinct modes aid in designing an OS?
Preventing user programs from interfering with system-level operations (accidentally or maliciously causing system crashes or other errors)
What is the purpose of system call in an OS?
System call provides the services of the operating system to the user programs via the Application Program Interface (API)
What is an Open System Call, its Syntax and Conditions that cause them to fail
Initialises access to a file in a file system, also specifies the mode in which the file should be opened (flags) (e.g., read, write, append)
May fail due to various factors, file not found, permission denied, invalid pathname
int open(const char *pathname, int flags, mode_t mode);
What is an Close System Call, its Syntax and Conditions that cause them to fail
Close an open file in an operating system
May fail due to invalid file descriptor, interrupted by a signal, I/O error
int close(int fd);
What is an Read System Call, its Syntax and Conditions that cause them to fail
Read data from a file or other input source into a buffer in user memory
May fail due to invalid file descriptor, permission denied, invalid buffer
ssize_t read(int fd, void *buf, size_t count);
What is an Lseek System Call, its Syntax and Conditions that cause them to fail
lseek is used to reposition the read/write file offset of an open file descriptor
May fail due to invalid file descriptor, unsupported device, invalid whence parameter, out-of-bounds offset
off_t lseek(int fd, off_t offset, int whence);
Virtual Machine features
- Isolation, operates independently
- Resource allocation and virtualisation, share the physical hardware of the host
- Platform independence, can emulate a different operating system than the host machine
- Security, provide an isolated environment that can be used to run potentially unsafe applications
Virtual Machine downsides
- Performance overhead, introduce additional layers between the hardware and the operating system
- Resource contention, share the physical resources of the host machine, degrade performance
- Limited hardware access, require direct hardware access, may face limitations or degraded performance
- Compatibility issues can limit usability for certain use cases