I'm trying to compile this software called OSP. If you are familiar with it, this is OSP version one (written circa 1990). It compiles fine an this old Sun Solaris server, but on this new server running SUSE Linux 10 I get errors. Here's the command I'm using to compile:
cc -lm -w *.c
I'm probably just using bad command line options causing it to link incorrectly. I'm really rusty on my C code, but I need to get this program working so a professor can teach his OS course.
Here are the errors for the first file (all the remaining errors are similar):
Code:
cpu.c:198: error: static declaration of âfind_highest_priority_pcbâ follows non-static declaration
cpu.c:43: error: previous declaration of âfind_highest_priority_pcbâ was here
cpu.c:249: error: static declaration of âduplicate_pcbâ follows non-static declaration
cpu.c:94: error: previous implicit declaration of âduplicate_pcbâ was here
Here is the section of code containing Line 43 (43 is the last line in this snippet)
Code:
#include "cpu.h"
#include "cpu.private.h"
#define NULL 0
#include "ospmasks.h"
#define cost(pcb) ( pcb->last_dispatch + pcb->last_cpuburst + start_cost(pcb) )
#define is_queue_empty() ( (ready_q.head == NULL) && (ready_q.tail == NULL) ?\
true : false )
extern int ______trace_switch;
extern int ______MASK;
extern check_pcb();
extern check_page_table();
extern osp_abort();
PCB *find_highest_priority_pcb();
Line 94 is the first if statement //i.e. if (!duplicate_pcb(pcb)) {
Code:
PUBLIC
insert_ready(pcb)
PCB *pcb;
{
READY_Q *new_process;
/* check PCB pointer */
check_pcb(pcb,1,"CPU.insert_ready","","upon entering routine");
if (!duplicate_pcb(pcb)) {
pcb->status = ready;
pcb->priority = cost(pcb);
new_process = (READY_Q *)malloc(sizeof(READY_Q));
new_process->pcb = pcb;
new_process->next = NULL;
if (is_queue_empty() == true) { /* is_queue_empty is a macro */
ready_q.head = new_process;
ready_q.tail = new_process;
}
else {
ready_q.tail->next = new_process;
ready_q.tail = new_process;
}
}
else
printf("CLOCK> %6d#*** WARNING: CPU.insert_ready>\n\t\tTrying to insert duplicate PCB %d; duplicate discarded\n\n\n",get_clock(),pcb->pcb_id);
} /* insert ready */
And here's how the find_highest_priority_pcb function is written. Line 198 is actually the line with the bracket on it following the function declaration.
Code:
PRIVATE
PCB *find_highest_priority_pcb()
{
READY_Q *lowest, *next_rdy, *tmp_ptr; /* pointer to READY_Q */
PCB *ret_pcb;
lowest = ready_q.head; /* assume head pcb has the lowest cost */
next_rdy = ready_q.head;
while(next_rdy != NULL){
if (next_rdy->pcb->status != waiting &&
next_rdy->pcb->priority < lowest->pcb->priority)
lowest = next_rdy;
next_rdy = next_rdy->next;
}
/* remove the lowest from the ready_q */
if (lowest == ready_q.head)
ready_q.head = ready_q.head->next;
else {
tmp_ptr = ready_q.head;
while(tmp_ptr->next != lowest)
tmp_ptr = tmp_ptr->next;
if (tmp_ptr->next == ready_q.tail)
ready_q.tail = tmp_ptr;
tmp_ptr->next = lowest->next;
}
ret_pcb = lowest->pcb;
free(lowest);
return(ret_pcb);
}
And finally, here is how the duplicate_pcb function is written (this function doesn't appear in the declarations section)
Code:
PRIVATE
int duplicate_pcb(pcb)
PCB *pcb;
{
READY_Q *tmp_ptr;
int found;
found = FALSE;
tmp_ptr = ready_q.head;
while(tmp_ptr != NULL){
if (tmp_ptr->pcb->pcb_id == pcb->pcb_id)
found = TRUE;
tmp_ptr = tmp_ptr->next;
}
return(found);
}
Any ideas?