• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

ProjectsGeek

Student Database using AWK Programming

April 4, 2011 by ProjectsGeek 5 Comments

Student Database using AWK Programming 

 

Write a program to handle student data base with options given below

a) Create data base.

b) View Data Base.

c) Insert a record.

d) Delete a record.

e) Modify a record.

f) Result of a particular student.

g) Exit.

Student Database using AWK

 clear  
 echo "1. create database "  
 echo "2. view database "  
 echo "3. insert a record "  
 echo "4. delete record "  
 echo "5. modify a record "  
 echo "6. result of particular student "  
 echo "7. exit"  
 echo " enter ur choice "  
 read d  
 case $d in  
 1)  
    echo " enter rollnumber of student "  
   read rn  
   echo " enter name of student "  
   read nm  
   echo " enter marks sanskrit "  
   read sk  
   echo " enter marks english "  
   read eg  
   echo " enter marks hindi "  
   read hn  
   record="$rn :$nm: $sk: $eg: $hn "  
   awk 'BEGIN{ print "'"$record"'">"stud" }'   
   ;;  
 2) awk 'BEGIN{print "rollno name smarks emarks hmarks"}{print $0}' stud;;  
 3)   
   echo " enter rollnumber of student "  
   read rn  
   echo " enter name of student "  
   read nm  
   echo " enter marks sanskrit "  
   read sk  
   echo " enter marks english "  
   read eg  
   echo " enter marks hindi "  
   read hn  
   record="$rn: $nm: $sk: $eg: $hn "  
   awk 'BEGIN { print "'"$record"'">>"stud" }'  
    ;;  
 4) echo " enter roll number "  
   read rn  
   awk 'BEGIN{FS=":"}$1=='$rn' {print }' stud  
   echo "RECORD FOUND "  
   awk 'BEGIN{FS=":"}$1!='$rn'{print >"temp"}' stud  
   cp temp stud  
   ;;  
 5) echo " enter roll number "  
   read rn1  
   awk 'BEGIN{FS=":"}$1=='$rn1' {print }' stud  
   echo " enter roll number "  
   read rn  
   echo " enter name of student "  
   read nm  
   echo " enter marks sanskrit "  
   read sk  
   echo " enter marks english "  
   read eg  
   echo " enter marks hindi "  
   read hn  
   record="$rn: $nm: $sk: $eg: $hn "  
   var=`awk 'BEGIN{FS=":"}$1=='$rn1' {print NR}' stud `  
   echo $var  
   awk 'BEGIN{FS=":"}NR<'$var'{print >"temp"}' stud  
   echo $record>>temp  
   var3=`awk 'END{print NR}' stud `  
   var2=`expr $var3 - $var `  
   awk 'BEGIN{FS=":"}NR>'$var2' && NR<'var3' {print >>"temp"}' stud  
   cp temp stud  
 ;;  
 6) echo " enter roll number "  
   read rn  
   echo "printing result "  
   awk 'BEGIN{FS=":"}$1=='$rn' {print }' stud  
   echo "RECORD FOUND "  
 ;;  
 7) ;;  
 * ) echo "enter right choice"  
 esac

 

Other Projects to Try:

  1. Database connectivity in Java with MYSQL
  2. Student Database using Shell Programming OS problem
  3. Factorial,Greatest Number, Palindrome AWK
  4. Student Database in C Language
  5. Student Database using Virtual functions in C++

Filed Under: Operating System . Linux Assignments

Factorial,Greatest Number,String Palindrome Shell code

April 4, 2011 by ProjectsGeek Leave a Comment

Factorial,Greatest Number,String Palindrome using Shell Programming

 

Menu driven program for Factorial,Greatest Number,String Palindrome

 

a) Find factorial of a no.

b) Find greatest of three numbers

c) Find a prime no

d) Find whether a number is palindrome

e) Find whether a string is palindrome

 Factorial,Greatest Number,String Palindrome Shell Programming Code

 

palins()  
 {  
   echo “ Enter a String to check for Palindrome “  
   read str  
   i=1  
   y=`echo $str | wc -c`   
   y=`expr $y - 1`  
   z=$y  
   echo “The Length of String $y”  
   while [ $y -ne 0 ]  
   do  
   z=`echo $str | cut -c $i`  
   w=`echo $str | cut -c $y`  
   if [ "$z" != "$w" ]  
   then  
   echo “ The Given String $str is not Palindrome ”  
   y=0  
   else  
   i=`expr $i + 1`  
   y=`expr $y - 1`  
   fi  
   done  
   if [ "$z" = "$w" ]  
   then  
    echo “The Given String $str is a Palindrome”  
   fi  
 }  
 palinn()  
 {  
  echo -n "Enter number : "  
  read n  
  sd=0  
  rev=""  
  on=$n  
  while [ $n -gt 0 ]  
  do  
   sd=$(( $n % 10 )) # get Remainder  
   n=$(( $n / 10 )) # get next digit  
   rev=$( echo ${rev}${sd} )  
  done  
  if [ $on -eq $rev ];  
  then  
   echo "Number is palindrome"  
  else  
   echo "Number is NOT palindrome"  
  fi  
 }  
 great()  
 { echo "enter first number"  
  read a1  
  echo "enter first number"  
  read a2  
  echo "enter first number"  
  read a3  
  if [ $a1 -gt $a2 ] && [ $a1 -gt $a3 ]; then  
  echo "first number $a1 is greatest"  
  elif [ $a2 -gt $a1 ] && [ $a2 -gt $a3 ]; then  
  echo "second number $a2 is greatest"  
  elif [ $a3 -gt $a1 ] && [ $a3 -gt $a2 ]; then  
  echo "third number $a3 is greatest"  
  fi  
 }  
 fact()  
 {  
  echo "enter the number to find the factorial"  
  read b  
  c=1  
  while [ "$b" -gt 0 ]; do  
  c=$(($c * $b))  
  b=$(($b-1))  
  done  
  echo "factorial is $c "  
 }  
 clear  
 echo "1. factorial "  
 echo "2. greatest number "  
 echo "3. palindrome "  
 echo "4. palindrome string "  
 echo "5. exit"  
 echo "6. enter ur choice "  
 read d  
 case "$d" in  
 1) echo " factorial "  
   fact;;  
 2) echo "greatest"  
   great;;  
 3) echo "palindrome"  
    palinn ;;  
 4) palins ;;  
 5) ;;  
 * ) echo "enter right choice"  
 esac

 

 

Other Projects to Try:

  1. Factorial,Greatest Number, Palindrome AWK
  2. string operations such as Copy, Length, Reversing, Palindrome, Concatenation
  3. Student Database using Shell Programming OS problem
  4. String Operations with Pointers
  5. Student Database using AWK Programming

Filed Under: Operating System . Linux Assignments

Student Database using Shell Programming OS problem

April 4, 2011 by ProjectsGeek 2 Comments

Student Database using Shell Programming

 

Write a program to handle student data base with options given below :

a) Create data base.

b) View Data Base.

c) Insert a record.

d) Delete a record.

e) Modify a record.

f) Result of a particular student.

g) Exit.

Student Database using Shell Programming Code

 

 clear  
 echo "1. create database "  
 echo "2. view database "  
 echo "3. insert a record "  
 echo "4. delete record "  
 echo "5. modify a record "  
 echo "6. result of particular student "  
 echo "7. exit"  
 echo " enter ur choice "  
 read d  
 case $d in  
 1)  
    echo " enter rollnumber of student "  
   read rn  
   echo " enter name of student "  
   read nm  
   echo " enter marks sanskrit "  
   read sk  
   echo " enter marks english "  
   read eg  
   echo " enter marks hindi "  
   read hn  
   record="$rn $nm $sk $eg $hn "  
   echo $record>stud   
   ;;  
 2) echo " showing database of student"  
   cat stud ;;  
 3)   
   echo " enter rollnumber of student "  
   read rn  
   echo " enter name of student "  
   read nm  
   echo " enter marks sanskrit "  
   read sk  
   echo " enter marks english "  
   read eg  
   echo " enter marks hindi "  
   read hn  
   record="$rn $nm $sk $eg $hn "  
   echo $record>>stud  
    ;;  
 4) echo " enter roll number "  
   read rn  
   grep ^$rn stud  
   if [ $? -ne 0 ]; then  
   echo "record for roll number does not exist "  
   else  
   grep -v $rn stud>>tmp  
   cp tmp stud  
   echo "deletion complete "  
   fi  
   ;;  
 5) echo " enter roll number "  
   read rn1  
   grep ^$rn stud  
   if [ $? -ne 0 ]; then  
   echo "record for roll number does not exist "  
   else  
   echo " enter roll number "  
   read rn  
   echo " enter name of student "  
   read nm  
   echo " enter marks sanskrit "  
   read sk  
   echo " enter marks english "  
   read eg  
   echo " enter marks hindi "  
   read hn  
   record="$rn $nm $sk $eg $hn "  
   var=`grep -n ^$rn1 stud | cut -c 1`  
   echo $var  
   var1=`expr $var - 1`  
   head -$var1 stud>temp  
   echo $record>>temp  
   var3=`wc -l < stud`  
   var2=`expr $var3 - $var `  
   tail -$var2 stud>>temp  
   cp temp stud  
    fi  
 ;;  
 6) echo " enter roll number "  
   read rn  
   echo "printing result "  
   grep ^$rn stud  
 ;;  
 7) ;;  
 * ) echo "enter right choice"  
 esac

 

Other Projects to Try:

  1. Student Database using AWK Programming
  2. Simple Student Database using C Language
  3. Factorial,Greatest Number,String Palindrome Shell code
  4. Student Database using Virtual functions in C++
  5. Student Database in C Language

Filed Under: Operating System . Linux Assignments

Bankers Algorithm using C Language OS problem

April 4, 2011 by ProjectsGeek Leave a Comment

Bankers Algorithm using C Language OS problem

 

 Bankers Algorithm for deadlock detection and avoidance.

 Bankers Algorithm code

# include  
 # include  
 # include  
 # define maxn 10  
 typedef struct banker  
 {  
  int available[maxn] ;  
  int claim[maxn][maxn] ;  
  int allocation[maxn][maxn] ;  
  int need[maxn][maxn] ;  
  int request[maxn];  
 }banker ;  
 void display(int,int,int resource[maxn],banker);  
 void bankersalgo(int nm,int resource [maxn],int rs);  
 int safe(int rs,int nm,int resource [maxn],banker) ;  
 void main()  
 {  
  int ch=0,nm=0,i,j,k,resource[maxn],request[maxn],rs ,flag=0;  
  char temp1;  
  struct banker bankers,b ;  
  clrscr() ;  
  do  
  {  
    printf("\t\t\t\t***MAIN MENU***\n") ;  
    printf("\t\t\t\t1.ENTER MATRICES\n");  
    printf("\t\t\t\t2.DISPLAY MATRICES \n");  
    printf("\t\t\t\t3.BANKERS ALGORITM (SAFETY & ALLOCATION\n" );  
    printf("\t\t\t\t4.EXIT\n");  
    printf("\t\t\t\tENTER UR CHOICE!!\n");  
    scanf("%d",&ch);  
    switch (ch)  
    {  
    case 1:  
     clrscr();  
     printf("ENTER NO OF PROCESS!!\n") ;  
     scanf("%d",&nm);  
     printf("ENTER NO OF RESOURCE !!\n") ;  
     scanf("%d",&rs);  
     for(i=0;i<rs;i++) <br="">     {  
       printf("ENTER RESOURCE MATRIX %d!!\n",i) ;  
       scanf("%d",&resource[i]) ;  
     }  
     printf("ENTER CLAIM MATRIX!!\n") ;  
     for(i=0;i<nm;i++) <br="">     {  
       for(j=0;j<rs;j++) <br="">       {  
         printf("\nENTER %d %d!!\n",i,j) ;  
         scanf("%d",&bankers.claim[i][j]) ;  
         if(bankers.claim[i][j]>resource[j])  
         {  
           printf(" WRONG VALUES ENTERED") ;  
           j--;  
         }  
       }  
     }  
     for(i=0;i<nm;i++) <br="">     {  
       for(j=0;j<rs;j++) <br="">       {  
         bankers.allocation[i][j]=0;  
         bankers.available[j]=resource[j];  
       }  
     }  
       clrscr();  
       display(nm,rs,resource,bankers);  
       printf("\nENTER ALLOCATION MATRIX!!\n") ;  
       for(i=0;i<nm;i++) <br="">       {  
         for(j=0;j<rs;j++) <br="">         {  
           printf("\nENTER %d %d!!",i,j) ;  
           scanf("%d",&bankers.allocation[i][j]) ;  
           if((bankers.allocation[i][j]>bankers.claim[i][j]) && (bankers.allocation[i][j]>bankers.available[j]))  
           {  
             printf(" WRONG VALUES ENTERED") ;  
             j--;  
           }  
           else  {  
             bankers.available[j]=bankers.available[j]-bankers.allocation[i][j];  
             bankers.need[i][j]=bankers.claim[i][j]-bankers.allocation[i][j];  
             }  
         }  
         display(nm,rs,resource,bankers);  
       }  
       break ;  
    case 2:  
     display(nm,rs,resource,bankers);  
     break ;  
    case 3:  
     i=safe(rs,nm,resource,bankers) ;  
     display(nm,rs,resource,bankers);  
     do  
     {  
     if(i==1)  
     {  
       printf("\n Enter the request process no P");  
       scanf("%d",&j);  
       printf("\n Enter process %d's request",j);  
       for(k=0;k<rs;k++) <br="">       {  
         scanf("%d",&request[k]);  
         if((request[k]>bankers.need[j][k])&& (request[k]>bankers.available[k]))  
         {  
           printf("\n Not valid request");  
           k--;  
         }  
       }  
           b=bankers;  
           for(k=0;k<rs;k++) <br="">           {  
             b.allocation[j][k]+=request[k];  
             b.need[j][k]-=request[k];  
             b.available[k]-=request[k];  
           }  
           display(nm,rs,resource,b);  
           printf("\n The new state's safety is checking");  
           i=safe(rs,nm,resource,b);  
           if(i==1)  
           {    display(nm,rs,resource,b);  
             bankers=b;  
             printf(" This is a Current state ");  
           }  
           else  
           {  
             display(nm,rs,resource,bankers);  
             printf(" This is a Current safe state ");  
           }  
          printf("\nDo u want to add more request on current system(0/1)");  
          scanf("%d",&flag);  
       }  
     else  
     {  
       printf("\n Current system is unsafe state");  
       exit(0);  
      }  
      }while(flag==1);  
      break ;  
    default :  
      printf("ENTER RIGHT OPTION!!\n") ;  
   }  
  }while(ch!=4 );  
 }  
 void display(int nm,int rs,int resource[maxn],banker bankers)  
 {  
   int i,j;  
   clrscr();  
   printf("Total instances of resources are:-");  
   for(i=0;i<rs;i++) <br="">     printf("\t%d",resource[i]);  
   printf("\nClaim \t Alloc \t Need");  
   for(i=0;i<nm;i++) <br="">   {  
     printf("\n");  
     for(j=0;j<rs;j++) <br="">       printf(" %d",bankers.claim[i][j]);  
     printf("\t");  
     for(j=0;j<rs;j++) <br="">       printf(" %d",bankers.allocation[i][j]);  
     printf("\t");  
     for(j=0;j<rs;j++) <br="">     {  
       bankers.need[i][j]=bankers.claim[i][j]-bankers.allocation[i][j];  
       printf(" %d",bankers.need[i][j]);  
     }  
   }  
   printf("\nCurrent avialble is :");  
   for(i=0;i<rs;i++) <br="">     printf("%d ", bankers.available[i]);  
   getch();  
 }  
 int safe(int rs,int nm,int resource[maxn],banker bankers)  
 {  
  int array[maxn],possible=1,i=0,j=0,k=0 ,flag[10];  
  banker b=bankers;  
  for(i=0;i<nm;i++) <br="">  {   array[i]=0;  
   flag[i]=0;  
  }  
  for(i=0;i<nm;i++) <br="">  {  
    if(flag[i]==0)  
    {  
     for(j=0;j<rs;j++) <br="">     {  
       if(b.need[i][j]<=b.available[j])  
       {  
         possible=0 ;  
       }  
       else  
       {  
         possible=1;  
         break;  
       }  
     }  
     if(possible==1)  
     {  
       printf("\n%d PROCESS CAN NOT PROCESSED",i) ;  
     }  
     else  
     {  
       printf("\nPROCESS%d IS PROCESSING",i) ;  
       for(j=0;j<rs;j++) <br="">       {  
         b.available[j]+=b.allocation[i][j];  
         b.allocation[i][j]=0;  
         b.claim[i][j]=0;  
       }  
       flag[i]=1;  
       array[k++]=i;  
       i=-1;  
       display(nm,rs,resource,b);  
     }  
    }  
  }  
 for(i=0;i<4;i++)  
 {  
   if(flag[i])  
     k=1;  
   else {  
     k=0;  
     break;  
     }  
 }  
 if(k==1)  
 {  
   printf("\n System is in safe state with sequence");  
 }  
 for(i=0;i<nm;i++) <br="">   printf(" %d",array[i]);  
 getch();  
 return k;  
 }

 


 

 

Other Projects to Try:

  1. Paging Algorithms using C language OS problem
  2. Krushkals algorithm Code in C Language
  3. Prims algorithm Code in C Language
  4. Operations on matrices like addition, multiplication, saddle point, magic square ,inverse & transpose
  5. Set operations – Union, Intersection, Difference, Symmetric Difference using C

Filed Under: Operating System

Inter process Communication(IPC)-Client Code

April 4, 2011 by ProjectsGeek Leave a Comment

Inter process Communication(IPC) client Server  Code Operating System Problem

 

Inter process Communication Client Code using C language

 

  • Interprocess Communication for Producer Consumer problem in UNIX (Pipes or Shared Memory)
  • Students must submit the term work in the form of journal.
  • Each assignment has to be well documented with problem definition, theory and code documentation.
  • Staff in charge will assess the assignments continuously and grade or mark each assignment on completion date declared for each assignments.

IPC Client Code using C language

 

 #include  
 #include  
 #include  
 #include  
 #define SIZE 124  
 int main()  
 {  
   char *buff,*str;  
   buff=(char*)malloc(124);  
   str=(char*)malloc(124);  
 *str='\0';    
 int shmid,i=0;  
   if((shmid=shmget(9999,SIZE,IPC_CREAT|0666))<0)  
   printf("\nERROR IN SHMID\n");  
   if((buff=shmat(shmid,NULL,0))<0)  
     printf("ERROR IN SHM ATTACH\n");  
 while(1)  
   {  
     if(*str!='\0')  
     {  
     printf("\nTHE SERVER JUST SEND THIS MESSAGE\n\n");  
     fputs(str,stdout);  
     break;  
     }  
 strncpy(str,buff,SIZE);  
   }  
 *str='\0';  
 *buff='\0';  
 printf("\nREPLY \n\n");  
 fgets(str,SIZE,stdin);  
 strncpy(buff,str,SIZE);  
 sleep(1);  
 *buff='\0';  
 return(0);  
 }  
 Server   
 #include  
 #include  
 #include  
 #include  
 #define SIZE 124  
 int main()  
 {  
   char *buff,*str;  
   buff=(char*)malloc(124);  
   str=(char*)malloc(124);  
   int shmid;  
   if((shmid=shmget(9999,SIZE,IPC_CREAT|0666))<0)  
   printf("\nERROR IN SHMID\n");  
   if((buff=shmat(shmid,NULL,0))<0)  
     printf("ERROR IN SHM ATTACH\n");  
   printf("\nWRITE YOUR MSG\n");  
   fgets(str,SIZE,stdin);  
   strncpy(buff,str,SIZE);  
 sleep(1);  
 *buff='\0';  
 *str='\0';  
 printf("\n SERVER IS WAITING FOR REPLY........\n");  
 while(1)  
 {  
 if(*str!='\0')  
 {  
 printf("\nCLIENT JUST GAVE REPLY\n");  
 fputs(str,stdout);  
 break;  
 }  
 strncpy(str,buff,SIZE);  
 }  
   return(0);  
 }

 

Other Projects to Try:

  1. Regular Expression to DFA Code in C Language
  2. Lexical analyzer Code in C Language
  3. Dijkstra Algorithm in C Language
  4. string operations such as Copy, Length, Reversing, Palindrome, Concatenation
  5. Macro Processor Pass Two in C Language

Filed Under: Operating System

Paging Algorithms using C language OS problem

April 4, 2011 by ProjectsGeek 2 Comments

 Paging Algorithms Operating System

 

Write the simulation Paging Algorithms program for demand paging and show the page scheduling and total number of page faults according to MFU page replacement algorithm. Assume the memory of ‘n’ frames.

Paging Algorithms using C language

 # include  
 # include  
 # include  
 # define maxn 50  
 typedef struct  page  
 {  
   int frame ;  
   int count[maxn],curr[maxn] ;  
 }page ;  
 struct page p ;  
 void fifo(int pages,int page[]) ;  
 void lru(int pages ,int page[]) ;  
 void optimal(int pages,int page[]) ;  
 void main()  
 {  
  int ch=0,pages=0,i,j,page[maxn],frames=0,temp3,temp4 ;  
  char temp ;  
  clrscr() ;  
  do  
  {  
    printf("\t\t\t\****main menu****\n") ;  
    printf("\t\t\t1.enter the page information\n");  
    printf("\t\t\t2.dispaly page info\n");  
    printf("\t\t\t3.fifo\n" );  
    printf("\t\t\t4.\lru\n") ;  
    printf("\t\t\t5.\optimal\n") ;  
    printf("\t\t\t6.exit\n");  
    printf("\t\t\tenter ur choice\n");  
   scanf("%d",&ch);  
   switch (ch)  
   {  
    case 1:  
      clrscr();  
      printf("enter the no of pages\n");  
      scanf("%d",&pages) ;  
      printf("enter pages\n");  
      for(i=0;i<pages;i++) <br="">      {  
       printf("page %d\n",i);  
       scanf("%d",&page[i]) ;  
      }  
      printf("enter number of frames .....\n");  
      scanf("%d",&p.frame) ;  
      break ;  
    case 2:  
      printf("no of pages%d\n",pages);  
       printf("page sequence \n");  
       for(i=0;i<pages;i++) <br="">       {  
       printf("page %d\n",page[i]);  
       }  
       printf("no of frames/%d",p.frame);  
      break ;  
    case 3:  
       fifo(pages,page) ;  
       break ;  
    case 4:  
       lru(pages ,page);  
      break ;  
    case 5:  
        optimal(pages ,page);  
      break ;  
    case 6:  
      break ;  
   }  
 }while(ch!=6 );  
 }  
 void fifo(int pages,int page[])  
 {  
  int i,j,k,flag=0,temp=0,fault=0 ;  
  for(i=0;i<p.frame;i++) <br="">

  {  
     p.curr[i]=-1 ;  
     p.count[i]=100 ;  
     printf("\tpage%d",i+1) ;  
  }  
  printf("\tfault\n\n");  
  for(i=0;i<pages;i++) <br="">  {  
     flag=0 ;  
     temp=0 ;  
     for(j=0;j<p.frame;j++) <br="">

     {  
           if(p.curr[j]==page[i])  
           {  
             flag=1 ;  
             break ;  
           }  
           if(temp<p.count[j]) <br="">

           {  
               temp=p.count[j] ;  
               k=j ;  
           }  
     }  
     for(j=0;j<p.frame;j++) <br="">

     {  
         if(flag==0 && k==j)  
         {  
           p.curr[j]=page[i] ;  
           p.count[j]=1 ;  
           fault++ ;  
         }  
         else  
         if(j<fault) <br="">         p.count[j]++;  
         if(p.curr[j]!=-1)  
         printf("\t%d",p.curr[j]) ;  
     }  
     if(flag==0)  
     printf("\t\t\t*") ;  
     printf("\n") ;  
  }  
  printf("no of page fault%d",fault);  
 }  
 void lru(int pages ,int page[])  
 {  
  int i,j,k,flag=0,temp=0,fault=0 ;  
  for(i=0;i<p.frame;i++) <br="">

  {  
     p.curr[i]=-1 ;  
     p.count[i]=100 ;  
     printf("\tpage%d",i+1) ;  
  }  
  printf("\tfault\n\n");  
  for(i=0;i<pages;i++) <br="">  {  
     flag=0 ;  
     temp=0 ;  
     for(j=0;j<p.frame;j++) <br="">

     {  
           if(p.curr[j]==page[i])  
           {  
             flag=1 ;  
             p.count[j]=0 ;  
             break ;  
           }  
           if(temp<p.count[j]) <br="">

           {  
               temp=p.count[j] ;  
               k=j ;  
           }  
     }  
     for(j=0;j<p.frame;j++) <br="">

     {  
         if(flag==0 && k==j)  
         {  
           p.curr[j]=page[i] ;  
           p.count[j]=1 ;  
           fault++ ;  
         }  
         else  
         if(j<fault) <br="">         p.count[j]++;  
         if(p.curr[j]!=-1)  
         printf("\t%d",p.curr[j]) ;  
     }  
     if(flag==0)  
     printf("\t\t\t*") ;  
     printf("\n") ;  
  }  
  printf("no of page fault%d",fault);  
 }  
 void optimal(int pages,int page[])  
 {  
  int i,j,k,flag=0,temp=0,fault=0,s ;  
  for(i=0;i<p.frame;i++) <br="">

  {  
     p.curr[i]=-1 ;  
     p.count[i]=100 ;  
     printf("\tpage%d",i+1) ;  
  }  
  printf("\tfault\n\n");  
  for(i=0;i<pages;i++) <br="">  {  
     flag=0 ;  
     temp=0 ;  
     for(j=0;j<p.frame;j++) <br="">

     {  
           if(p.curr[j]==page[i])  
           {  
             flag=1 ;  
             p.count[j]=0 ;  
             break ;  
           }  
           if(temp<p.count[j]) <br="">

           {  
               temp=p.count[j] ;  
               k=j ;  
           }  
     }  
     for(j=0;j<p.frame;j++) <br="">

     {  
         if(flag==0 && k==j)  
         {  
           p.curr[j]=page[i] ;  
           p.count[j]=0 ;  
           fault++ ;  
         }  
         else  
         if(j<fault) <br="">         {  
           p.count[j]=0 ;  
           for(s=i+1;s<pages;s++) <br="">           {  
             if(page[i]==p.curr[j])  
             break ;  
             else  
             p.count[j]++ ;  
           }  
         }  
         p.count[j]++;  
         if(p.curr[j]!=-1)  
         printf("\t%d",p.curr[j]) ;  
     }  
     if(flag==0)  
     printf("\t\t\t*") ;  
     printf("\n") ;  
  }  
  printf("no of page fault%d",fault);  
 }

 

Other Projects to Try:

  1. Bankers Algorithm using C Language OS problem
  2. How to Implement Hash Table using C language
  3. Operations on matrices like addition, multiplication, saddle point, magic square ,inverse & transpose
  4. Hash table code in C Language
  5. string operations such as Copy, Length, Reversing, Palindrome, Concatenation

Filed Under: Operating System

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 131
  • Page 132
  • Page 133
  • Page 134
  • Page 135
  • Go to Next Page »

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy