0

I am working on MINIX 3. I changed the process scheduler and I want to do some testing there now.

The problem is that when I want to use double I am getting an error. The interesting part is that if I declare and initialize a double variable in the global in the class, it is not showing an error, but when I want to use that same double variable inside a method, and try to compile MINIX 3 (version 3.1.6) I am getting this error:

/usr/lib/em_led: /usr/lib/i386/libc.a(exit.o): multiply defined (error)
Undefined:
     _test_variable (<---- the name of the variable is "test_variable")
make in /usr/src/kernel: Exit code 1
make in /usr/src/tools: Exit code 1
make: made 'image' look old

This happens when I use the command make hdboot in /usr/src/tools, which I use after make install

Does anybody know what the problem here is?

EDITED

The code is:

FORWARD _PROTOTYPE( struct proc * pick_proc, (void));
FORWARD _PROTOTYPE( void enqueue_head, (struct proc *rp));
double test_variable;

//(the Variable **test_variable** one is Declared on TOP of the class after the Includes and after the declarations of the Methods 

PRIVATE struct proc * pick_proc(void)
{
    register struct proc *rp;           /* process to run */
int q;              /* iterate over queues */
int proceset;
proc_nr_t proci;
if (first_time == 1)
{
    test_variable = 6.5;
}
user3774470
  • 29
  • 2
  • 10
  • 1
    You're showing two conflicting errors: `multiply defined (error)` and `Undefined: _test_variable`. Neither of these refers to `variable`. So, you need to show your code — where you think you define `test_variable` and and then worry about why you're getting multiply defined issues at the same time. It is common for compilers to add a leading underscore to your variable names. – Jonathan Leffler Dec 01 '15 at 04:41
  • @JonathanLeffler, I edited my post. Please take a look at the code – user3774470 Dec 01 '15 at 05:02
  • You've given a tentative definition of `test_variable`; that would normally be sufficient. You could think in terms of using `double test_variable = 6.5;` which might even mean you avoid the need for the `first_time` variable — the definition of which is not shown either. – Jonathan Leffler Dec 01 '15 at 05:30
  • This was just for testing purposes the `first_time` because `pick_proc` is called from every Process. So I just wanted to initialize one time. The problem as mentioned is that I cant initialize inside a method... and I NEED to initialize inside the method. I don't want a STATIC variable with the same value, I need to change and manipulate the value of this variable – user3774470 Dec 01 '15 at 05:45
  • OK. I'm sorry I can't help any more. I've not worked on Minix enough to have any good idea. What you're doing looks more or less kosher, and I don't know what's going wrong. – Jonathan Leffler Dec 01 '15 at 05:46
  • Is your test_variable *defined* in a .c file, or just *declared* in a .h file? Do you have the same problem if you replace 'double' by 'int' or 'float'? – Mathieu Dec 04 '15 at 13:24

1 Answers1

0
  1. try renaming your variable, and make it static too.

  2. I can't guarantee this about MINIX-3 specifically, but I'd bet you probably can't use floating point inside the scheduler or any other core subsystem, server, driver, or the kernel (use int or long).

Greg A. Woods
  • 2,663
  • 29
  • 26