0

I am modifying kernel of minix 3.1.6 as part of my undergraduate OS project, and I intend to first analyze the scheduling algorithm previously implemented with it by storing scheduling related info for each process in some file, which can be analyzed later.

While modifying proc.c, I am getting Multiply defined error when using fprintf() to store data in some file, at the same time fopen() is working fine.

I am very new to all this, so any help will be appreciated. Thanks in advance...........

here is the piece of code ..

PRIVATE void sched(rp, queue, front)
register struct proc *rp;           /* process to be scheduled */
int *queue;                 /* return: queue to use */
int *front;                   /* return: front or back */

{

/* This function determines the scheduling policy.  It is called whenever a
 * process must be added to one of the scheduling queues to decide where to
 * insert it.  As a side-effect the process' priority may be updated.  
 */
  int time_left = (rp->p_ticks_left > 0);   /* quantum fully consumed */
   /* Check whether the process has time left. Otherwise give a new quantum 
   * and lower the process' priority, unless the process already is in the 
   * lowest queue.  
   */
  if (! time_left) {                /* quantum consumed ? */
      rp->p_ticks_left = rp->p_quantum_size;    /* give new quantum */
      if (rp->p_priority < (NR_SCHED_QUEUES-1)) {
          rp->p_priority += 1;          /* lower priority */
      }
  }
    FILE *fp = fopen("/usr/newlog.txt","a");
   /* If there is time left, the process is added to the front of its queue, 
   * so that it can immediately run. The queue to use simply is always the
   * process' current priority.*/ 
  fprintf(fp,"{\nprocess name: %s\nprocess quantum: %d\ntime left: %d\nprocess queue: %d\n}\n\n",
  rp->p_name,rp->p_quantum_size,rp->p_ticks_left,rp->p_priority);
  *queue = rp->p_priority;
  *front = time_left;
   fclose(fp);
}
  • 2
    Post your code, some examples, the versions of everything your using, the compiler, etc.. – Magisch Oct 24 '15 at 06:38
  • @Magisch , I am compiling the whole kernel using "make install" as defined by the minix developers and it compiles whole source code with cc compiler or MINIX 3 C compiler from the Amsterdam Compiler Kit (ACK). – Shubham Upadhyaya Oct 24 '15 at 17:14

0 Answers0