google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.

Friday, January 18, 2019

RoundRobin Program of practical slip



 /* Implementation of RoundRobin method for CPU scheduling using Circular LL */
 


#include<stdlib.h>
#define newnode (struct node *)malloc(sizeof(struct node))
struct node
{ int jobno,time;
  struct node *next;
}*JOBQ=NULL;


void erase()
{ struct node *S,*T;
  if(JOBQ!=NULL)
  { for(T=JOBQ;T->next!=JOBQ; T=T->next) ;  // go to last node
    T->next=NULL;

    while(JOBQ!=NULL)  { S=JOBQ;  JOBQ=JOBQ->next;  free(S);  }
  }
}

void CreateJOBQ()
{ struct node *S;   int i,n;
  printf("\nHow many jobs?"); scanf("%d",&n);


  if(JOBQ!=NULL) erase(JOBQ);
  JOBQ=newnode;
  printf("\nEnter JOB No. & execution time in sec. "); scanf("%d %d",&JOBQ->jobno,&JOBQ->time);

  S=JOBQ;
  for(i=2;i<=n;i++)
  { S->next=newnode;
    S=S->next;
    printf("\nEnter JOB No. & execution time in sec. "); scanf("%d %d",&S->jobno,&S->time);
  }
  S->next=JOBQ;
}

void DisplayJOBQ()
{struct node *T=JOBQ;
  if(JOBQ==NULL) printf("\nJOB Q is Empty!");
  else
  { printf("\nJOB  Rem. Time");
    do{ printf("\n J%d : %d ",T->jobno,T->time);
    T=T->next;
      }while(T!=JOBQ);
  }
}

void ExecuteJOBQ()
{ struct node *T=JOBQ,*S=NULL,*t1;  int flag,timeslot=1,time=0; char choice;
  printf("\nEnter Time Slot (in sec.) "); scanf("%d",&timeslot);
  printf("\nclock CPU   JOBQ ");
  while(JOBQ!=NULL)
  {
    do{ flag=0;
    if(T->time<=timeslot)  // job remaining time < time slot
    { printf("\n%3d  J%d(%d) |--",time,T->jobno,T->time); // cpu allocated
      for(t1=T->next; t1!=T; t1=t1->next) printf(" J%d(%d) ",t1->jobno,t1->time);  // print JOBQ
      time+=T->time; // increment clock
      T->time=0; // job finished, delete from JOBQ
      if(T==JOBQ) // 1st job
      { if(JOBQ->next==JOBQ) // only 1 job in Q
        { JOBQ=NULL; free(T); T=NULL; } // JOBQ became empty
        else  // more jobs in Q
        {  for(t1=JOBQ;t1->next!=JOBQ; t1=t1->next) ;  // go to last node
           JOBQ=JOBQ->next;   t1->next=JOBQ;
           free(T);     T=JOBQ; flag=1;
        }
      }
      else // job other than 1st position
      {   S->next=T->next; free(T);  T=S->next;
      }

    }
    else  // job is executed for given time slot
    {  printf("\n%3d  J%d(%d) |--",time,T->jobno,T->time); // cpu allocated
       for(t1=T->next; t1!=T; t1=t1->next) printf(" J%d(%d) ",t1->jobno,t1->time); // print JOBQ

       T->time-=timeslot;
       time+=timeslot;
       S=T; T=T->next;  // go to next job
    }

    printf(" --|  Add New Job(y/n)? ");  choice=getche();
    if(choice=='y' || choice=='Y')
    { struct node *S1;
      if(JOBQ==NULL) // JOBQ empty
      { JOBQ=newnode; JOBQ->next=JOBQ;    // 1st job in Q
        printf("\nEnter JOB No. & execution time in sec. "); scanf("%d %d",&JOBQ->jobno,&JOBQ->time);
        T=JOBQ; flag=1;
      }
      else
      { for(S1=S;S1->next!=S; S1=S1->next) ;  // go to last node of JOBQ
        S1->next=newnode; S1=S1->next; S1->next=S;    // add new job at the end of JOBQ
        printf("\nEnter JOB No. & execution time in sec. "); scanf("%d %d",&S1->jobno,&S1->time);
      }
    }
      }while(T!=JOBQ || flag);
  }
  printf("\n%3d  -idle-",time);
}

char menu()
{ char choice='a';
  clrscr();
  printf("----- Round Robin ------");
  printf("\nC: Create New JOB Queue");
  printf("\nD: Display JOB Queue");
  printf("\nE: Execute JOB Queue");
  printf("\nX: exit");
  printf("\nEnter your choice : ");
  choice=getche();
  return toupper(choice);
}

void main()
{
  while(1)
  { switch(menu())
    { case 'X' : erase(); exit(0);  // release memory allocated to JOBQ
      case 'C' : CreateJOBQ();  break;
      case 'D' : DisplayJOBQ(); break;
      case 'E' : ExecuteJOBQ(); break;
      default  : printf("\7 Invalid Choice!");
    }
    printf("\npress any key to continue...");
    getch();
  }

}

Earning Money


To earn money is not so easy for everyone it depends on factors
Time
Age
Smartness
Luck
Legacy 

If you want to earn money make proper investments at proper time and at proper place.
Money word says itself:
M - Move
O - Overcome
N - Noble
E -  Energy
Y - Your true value

Earning money should have mind to solve problem which can be generated by creativity to produce a product which is problem solving product.
One will give you money only when he wants his work to be done for that money. One should be experienced in the work which he or she is doing to earn money with doing his marketing.
Money can be earned on :
Seconds basis,
Minutes basis,
Hourly basis,
Daily basis,
Weekly basis,
Monthly basis,
Quarterly basis,
Yearly basis

 It is done by
Manufactured basis,
Selling basis ,
Service basis,
Job basis,
Physical basis,
Mental basis,
Consulting basis,
Mode basis,
Salary basis,
Share market basis,
Interest basis,
Commission  basis

Make study and expert in the field by Blue Ocean Strategy so that you can make money easily on the market. think abut the future what are important and give priority to them accordingly.
Adopt technology and should be easily move with generation otherwise you will stay behind.
Make a statistical study in each of the cases.

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...