1

I am trying to change mechanism of scheduling in Minix203. I need for some reason global variable

unsigned short QuantTime[3] = {1,1,1};

I put it in the /usr/src/kernel/proc.c file, then added

extern unsigned short QuantTime[3];

to /usr/src/kernel/proc.h

I made a syscall which takes value from the array but it seems the array stays initialized to 0 even though I initialized it with 1.

The syscall works well because with the other one I can set values in this array and they read them once again getting expected results.

I'm make the syscall this way: test program -> _syscall -> _taskcall -> here in /usr/src/kernel/system.c Im getting the value

How can I initialize this array then?

Julian Rubin
  • 1,175
  • 1
  • 11
  • 23

2 Answers2

0
extern int var = 0;
int main(void)
{
 var = 10;
 return 0;
}

When extern is used with a variable, it’s only declared not defined. however as an exception, when an extern variable is declared with initialization(like in your case), it is taken as definition of the variable as well.

ashish
  • 361
  • 3
  • 8
  • 1
    So the answer is: "it should work properly"? It doesnt make sense to me... So extern of variable with initialization makes a copy? – Julian Rubin Mar 22 '15 at 18:56
0

It seems that something went wrong somewhere else. I took a fresh version of minix 2.0.3 and had no more troubles with this array.

Julian Rubin
  • 1,175
  • 1
  • 11
  • 23