CPU Scheduling algorithm implementation

#include
#include
#include
#include
#include


union REGS i, o ;
int x1,y1,click;
int count=1;
char *comments[]={
" ",
"Opps ?...Try it again!",
"C give yourself a chance!",
"Yes!! You can do it !",
"Think about 1 Million!",
"Don't give up Friend !",
"Ohhh... LOOSER..!!",
"Sorry..You loose !"
};

void main()
{

int x=50,y=50,gdriver = 9, gmode=2;
initgraph(&gdriver, &gmode, "c:\tc\bgi");
setcolor(LIGHTRED);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
outtextxy(240,200,"Developed by :");
outtextxy(240,250,"WWW");
rectangle(210,170,420,300);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(200,400,"Press any key to continue.........");
getch();
cleardevice();


showmouseptr();
setbkcolor(9); //sets the backgroundcolour.
setcolor(YELLOW);
outtextxy(20,445,"CLICK ON THE BUTTON "IGCT"");
unpressed(290,430,"EXIT");
unpressed(x,y,"IGCT");

while(1)//infinite loop.
{

getmousepos();

if(x1 >= x && x1 <= x+50 && y1 >= y && y1 <= y+30 )//checks if the
mouse pointer is over the button.
{ //where
x,x+50,y,y+50 are ((x,y))top,(x,y)bottom)co-ordinates.
hidemouseptr();
erasebutton(x,y);
x=random(600);
y=random(400);
//checks whether count=1 so as to display the button on the new
position for only once.

setcolor(9);
outtextxy(380,445,comments[count-1]);//to erase previousely written
things
setcolor(YELLOW);
outtextxy(380,445,comments[count]);
count++;

if(count==9)
{
setcolor(9);
outtextxy(380,445,comments[8]);//to erase previousely written
things
setcolor(YELLOW);
outtextxy(380,445,comments[1]);
count=2;
}

unpressed(x,y,"IGCT");
showmouseptr();


}
if(x1>=290&&x1<=340&&y1>=430&&y1<=460 && click==1)//checks if the mouse
pointer is over the "EXIT" button.
{ //for click==1 refer
to mousepos.h.
hidemouseptr();
pressed(290,430,"EXIT");
showmouseptr();
sound(1200);
delay(100);
nosound();
while(click!=0)
getmousepos();
break;
}

}

closegraph();
restorecrtmode();
}

unpressed(int x,int y,char *string) //display's an unpressed button.

{

setfillstyle(SOLID_FILL,CYAN);//sets the fill pattern and colour.
bar(x, y, x+50, y+30);//creates a box and the box is automatically
filled with the chosen colour.
setcolor(LIGHTCYAN);
line(x,y,x+50,y);//creates a white line just over the box.
line(x,y,x,y+30);

setcolor(EGA_DARKGRAY);
line(x,y+30,x+50,y+30);//creates a dark line just below the box.
line(x+2,y+31,x+50,y+31);
line(x+50,y,x+50,y+30);
line(x+51,y,x+51,y+31);
setcolor(BLUE);
outtextxy(x+10,y+12,string);//displays text on the box.
return 0;
}


pressed(int x,int y,char *string)

{
setfillstyle(SOLID_FILL,CYAN);
bar(x, y, x+50, y+30);
setcolor(EGA_DARKGRAY);
line(x,y,x+50,y);
line(x-1,y-1,x+51,y-1);
line(x,y,x,y+30);
line(x-1,y-1,x-1,y+30);

setcolor(LIGHTCYAN);
line(x,y+30,x+50,y+30);
line(x-1,y+31,x+50,y+31);
line(x+50,y,x+50,y+30);
line(x+51,y-1,x+51,y+31);

setlinestyle(DOTTED_LINE,1,NORM_WIDTH);
setcolor(EGA_DARKGRAY);
rectangle(x+4,y+4,x+46,y+26);//creates a dotted rectangle over the
box.
setcolor(BLUE);
outtextxy(x+10,y+12,string);
return 0;
}

erasebutton(int x,int y)//erases button.

{


setfillstyle(SOLID_FILL,getbkcolor());//gets the background colour


bar(x, y-1, x+51, y+31); // and fills the box with the
SOLID_FILL pattern.
return 0;
}

showmouseptr( ) //shows the mouse-pointer.

{

i.x.ax = 1 ;

int86 ( 0x33, &i, &o ) ;
return 0;
}
hidemouseptr()//hides the mouse pointer.
{
i.x.ax=2;
int86(51,&i,&o);//note:-0x33(hex)÷51(dec).
return 0;
}

getmousepos() //finds the mouse-pointer position.

{


i.x.ax = 3 ;

int86 ( 0x33, &i, &o ) ;

click = o.x.bx ;// if the left click button is pressed then click=1.

x1 = o.x.cx ; //x co-ordinate.

y1 = o.x.dx ; //y co-ordinate.

return 0;
}

Related Links :

4 comments:

  1. wat is exactly is this prog meant for?????????

    ReplyDelete
  2. This Program Rescheduled Your CPU , i.e Hardware interaction ...

    ReplyDelete
  3. you have a nice site. thanks for sharing this site. you can download lots of ebook from here

    http://feboook.blogspot.com

    ReplyDelete


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!