OS Module 1
OS Module 1
Operating System
INTRODUCTION
• The architecture (instruction set, memory organization, I/O, and bus structure) of most computers at the
machine-language level is primitive and awkward to program, especially for input/output.
• software, called a disk driver, deals with the hardware and provides an interface to read and write disk
blocks, without getting into the details. Operating systems contain many drivers for controlling I/O devices.
The Operating System as a Resource Manager
1. Text Section: A Process, sometimes known as the Text Section, also includes the
current activity represented by the value of the Program Counter.
2. Stack: The stack contains temporary data, such as function parameters, returns
addresses, and local variables.
3. Data Section: Contains the global variable.
4. Heap Section: Dynamically allocated memory to process during its run time.
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
void forkexample()
{
pid_t p;
p = fork();
if(p<0)
{
perror("fork fail");
exit(1);
}
// child process because return value zero
else if ( p == 0)
printf("Hello from Child!=%d",getpid());
3.The third reason for termination is an error caused by the process, often
due to
a program bug. Examples include executing an illegal instruction, referencing
nonexistent memory, or dividing by zero.
4.The fourth reason a process might terminate is that the process
executes a system call telling the operating system to kill some other
process.
nt child,parent;
pid_t p;
p = fork();
f(p<0)
perror("fork fail");
exit(1);
child=getpid();
// parent process because return value non-zero.
else
{ parent=getppid();
printf("Hello from Parent!=%d\n",getppid()); }
kill(p, SIGKILL);}
int main()
{
forkexample();
return 0;}