#title "DemOLiTioN"
#author Theur

#include stdio
#include Instances
#include Kernel

import void ForVIPsONLY();

export first;
export second;
export third;
int i;

void forth();

void second()
{
 while(1) printf("2");
}

void first(int a)
{
 ForVIPsONLY();//
 fork forth();//make 3rd fork, that will have KERNEL right
 secured{
 printf("\nThe mother instance (parent) is being executed.\n");
 printf("It has KERNEL right, so it can use ForVIPsONLY function\n");
 printf("It has just created 3rd fork with KERNEL rights.\n");
 printf("Now it will create a fork but with USER rights.\n");
 printf("That instance will cause an error, because it uses ForVIPsONLY()\n");

 fork(i) {
          printf("The next, %dth fork is being called (should cause an error).\n",i);
          forth();//that will be simple USER
         }
 printf("Setting priority USER to the fork.\n");
 scSet_Priority(scGet_Forked(scGet_This(),i),0);//the lowest priority
 printf("Done.\n");
 }
 while(1) printf("%d",a);
}

void third()
{
 while(1) printf("3");
}

void forth()
{ForVIPsONLY();//here we call illegal function
 while(1) printf("4");
}

