Revision System Progamming 2
Revision System Progamming 2
a. Define the term system software and its contribution to systems programming [2 marks]
System software refers to a set of programs that manage the resources and provide a
platform for running application software
Its main contribution to systems programming lies in providing an interface between
hardware and software, managing memory, handling input/output operations, and providing
essential services like file management and security. System software includes operating
systems, device drivers, utility programs, and compilers
Unnamed Pipes: Unnamed pipes, also called anonymous pipes, are created using the pipe
system call and are typically used for communication between parent and child processes or
between processes within the same process chain. Unnamed pipes are created implicitly
when the parent process forks, and they provide unidirectional communication between the
processes.
f. Describe the two system calls for changing a files permission [4 marks]
chmod: The chmod system call changes the permissions of a file or directory. It takes a
numeric mode or symbolic mode as an argument to specify the new permissions.
fchmod: The fchmod system call is similar to chmod, but it operates on a file descriptor
rather than a filename. It changes the permissions of the file associated with the specified file
descriptor.
g. List any three improvements in IA-32 architecture [3 marks]
Improvements in IA-32 Architecture:
Three improvements in IA-32 (x86) architecture:
i) Increased Address Space: IA-32 architecture has evolved to support larger address
spaces, allowing systems to address more memory. This enhancement enables support
for more extensive applications and data sets.
ii) Enhanced Instruction Set: Over time, IA-32 processors have introduced new
instructions and extensions to improve performance and support advanced computing
tasks like multimedia processing, cryptography, and virtualization.
iii) Improved Power Efficiency: Modern IA-32 processors incorporate power-saving
features and advanced microarchitecture techniques to improve energy efficiency and
reduce power consumption without compromising performance
h. Define virtualization and give examples of virtual systems [3 marks]
Virtualization is the process of creating a virtual (rather than actual) version of something, such
as a hardware platform, operating system, storage device, or network resources. It enables the
simultaneous execution of multiple operating systems or applications on a single physical
machine, allowing efficient resource utilization and isolation between virtual environments.
Examples of virtual systems include:
1. Virtual Machines (VMs): Software-based emulation of computer systems, where each
VM runs its own guest operating system on a host machine. Popular VM platforms
include VMware, VirtualBox, and Microsoft Hyper-V.
2. Containerization: Lightweight virtualization method that allows applications to run in
isolated environments called containers. Containers share the host operating system's
kernel and resources, providing fast startup times and efficient resource utilization.
Examples include Docker and Kubernetes.
3. Virtual Desktop Infrastructure (VDI): Centralized desktop virtualization technology
that hosts desktop environments on remote servers and delivers them to users over a
network. Users access virtual desktops using thin client devices, enabling flexible and
secure remote access to computing resources.
a. Write a system call to create a file myfile.doc and write into it “This is my file” [6 marks]
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
int main() {
int fd;
char *text = "This is my file\n";
// Create the file
fd = open("myfile.doc", O_CREAT | O_WRONLY, 0644);
// Write to the file
write(fd, text, strlen(text));
// Close the file
close(fd);
return 0;
}
b. Describe the following;
i) The c standard library
The C Standard Library is a collection of predefined functions and macros that
provide essential utilities for C programming.
The C Standard Library is specified by the ISO C standard and is available on most C
compilers
ii) The x library [4 marks]
The X Library (libX11) is a library used for programming graphical user interfaces (GUIs) on Unix
and Unix-like systems.
c. Write a shell script to display free space, time, partition disk, file system [6 marks]
#!/bin/bash
# Display free space
df -h
# Display current time
date
# Display partition information
fdisk -l
# Display file system information
Lsblk
df -h: Displays disk space usage in a human-readable format.
lsblk: Lists information about block devices (including partitions and mount
points).
File System Hierarchy: Unix-like systems follow a hierarchical file system structure, organizing
files and directories in a tree-like manner. This structure facilitates organization, navigation, and
management of files and directories.
a. Create a program that uses a linked list to store employees the details. Request user to enter
details of two employees and then print [6 marks]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Structure to represent an employee
struct Employee {
char name[50];
int age;
float salary;
struct Employee *next;
};
int main() {
struct Employee *head = NULL;
struct Employee *temp, *newNode;
char choice;
// Request user to enter details of two employees
for (int i = 0; i < 2; i++) {
newNode = (struct Employee *)malloc(sizeof(struct
Employee));
if (newNode == NULL) {
printf("Memory allocation failed!\n");
exit(1);
}
printf("Enter details of employee %d:\n", i + 1);
printf("Name: ");
scanf("%s", newNode->name);
printf("Age: ");
scanf("%d", &newNode->age);
printf("Salary: ");
scanf("%f", &newNode->salary);
newNode->next = NULL;
if (head == NULL) {
head = newNode;
temp = newNode;
} else {
temp->next = newNode;
temp = newNode;
}
}
// Print the details of employees stored in linked list
temp = head;
printf("\nDetails of employees:\n");
while (temp != NULL) {
printf("Name: %s, Age: %d, Salary: %.2f\n", temp->name,
temp->age, temp->salary);
temp = temp->next;
}
// Free allocated memory
while (head != NULL) {
temp = head;
head = head->next;
free(temp);
}
return 0;
}
b. List two examples of system software and two examples of application software [4 marks]
System Software:
Operating Systems (e.g., Windows, Linux, macOS)
Device Drivers (e.g., printer drivers, graphics drivers)
Application Software:
Web Browsers (e.g., Google Chrome, Mozilla Firefox)
Word Processors (e.g., Microsoft Word, LibreOffice Writer)
c. Explain the term kennel in system programming and briefly state the functions [4 marks]
In system programming, the term "kernel" refers to the core component of an operating
system. It acts as a bridge between hardware and software, managing system resources and
providing essential services. The functions of the kernel include:
Process Management: The kernel creates, schedules, and terminates processes. It allocates
CPU time to processes and ensures fair execution.
Memory Management: It manages system memory, allocating memory to processes and
managing virtual memory. The kernel also handles memory protection to prevent
unauthorized access.
File System Management: The kernel provides an interface for file operations, such as
reading, writing, and organizing data on storage devices. It manages file access permissions
and directory structures.
Device Management: The kernel controls communication with hardware devices, managing
device drivers and providing an abstraction layer for interacting with devices. It handles
device initialization, input/output operations, and device interrupts.
d. Write a simple bash script to perform a back up task form a directory of choice [6 marks]
#!/bin/bash
# Source directory to be backed up
source_dir="/path/to/source_directory"