Showing posts with label operating system. Show all posts
Showing posts with label operating system. Show all posts

Sunday, December 2, 2012

C Code FCFS First Come First Served Process Scheduling | Operating System

Write the programs to implement in C Code FCFS First Come First Served Process Scheduling   CPU scheduling algorithms. Take the inputs, Process name, Arrival time of the process, CPU execution time of the process. Use system timer to check the  time quantum and display after every second the process running on the CPU or if the CPUis idle until all the inputted
processes complete their execution. Calculate waiting time, turn around time for each
process.

C Code FCFS First Come First Served Process Scheduling | Operating System

 

 In this problem we can use time_t and get system time using time() which in the <time.h> header file so we need to import it also.Following Solution only for FCFS

Sunday, November 25, 2012

Program fifo and lru page replacement algorithm | Operating System


Code for first in first out as FIFO and Least Recently Used as LRU page replacement algorithm using structure in C programming with output | Operating System

Code for first in first out as FIFO and Least Recently Used as LRU page replacement algorithm using struture in C programming with output | Operating System

Friday, November 23, 2012

fork and exec method use together to execute Shell Commands | Operating System

A parent process should create a child process which will execute command "ls -l" using execlp() and will create its child process. The newly created child process should execute system call command "cat hello.txt" and create a child process. The newly created process should execute system call"whoami" and then terminate. Every parent process should wait for terminating its child process.

fork and exec method use together to execute Shell Commands | Operating System

 

Wednesday, October 10, 2012

Create Childs which use System Call Unix Linux Commands C program | Operating System

A parent process should create a child process which will execute system call command "ls"
and will create its child process. The newly created child process should execute system call command "cat" and create a child process. The newly created process should execute system call"whoami" and then terminate. Every parent process should wait for terminating its child process.

Solution :-
Following program demostrate you how to create processes using fork() method and how to  use system call to execute commands on shell terminal. Using simple wait() method parent wait for child execution till partent pause state. just try it out yourself/


Create 5 Child for Process | Operating system

Create 5 child processes for a process. The processes should be executing in
parallel. The parent process should wait till all the child processes are terminated.


Create Child Using Fork in C program | Operating System

Create a process. Fork to create a child process. Display pid, ppid, gid and uid in
the child process and display pid, gid and uid for the parent process

Solution:
This is small program to create process using fork() method as after call fork() it will return -1 if child creation fail,return 0 if child creation successful ,return child pid to  parent.

#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
#include<stdlib.h> 
void  main()
{
        pid_t pid;
        pid=fork();
        switch(pid)
        {
           case -1:printf("Child Creation Fail..!!");
                   exit(1); 
 
           case 0: 
                printf("I AM THE CHILD PROCESS\n");
                printf("The Child process id is %d  ppid is %d gid is %d uid id %d \n",getpid(),getppid(),getgid(),getuid());
               
       
           default:   printf("I AM THE PARENT PROCESS\n");
                printf("The Parent process id is %d gid %d uid %d \n",getpid(),getgid(),getuid());
        }
exit(0);
}

FCFS and Round Robin Schedular Implementation in C | Operating System

Write the programs to implement the below given CPU scheduling algorithms.
1.  FCFS
2.  RR
Take the inputs, Process name, Arrival time of the process, CPU execution time of
the process. For implementing RR additional input,  the desired time quantum should be
taken from the user. Calculate waiting time, turn around time for each
process.