begin process at 2012 05 27 19:20:02
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Système

 > SIMULATION DE LA MEMOIRE AVEC LA PAGINATION DE 1000 PAGES [TURBO C 3.0]

SIMULATION DE LA MEMOIRE AVEC LA PAGINATION DE 1000 PAGES [TURBO C 3.0]


 Information sur la source

Note :
Aucune note
Catégorie :Système Niveau :Débutant Date de création :08/02/2002 Date de mise à jour :09/02/2002 23:08:11 Vu :3 941

Auteur : hamdan

Ecrire un message privé
Site perso
Commentaire sur cette source (4)
Ajouter un commentaire et/ou une note

 Description

N'oubliez pas de changer le chemain dans le programme de la bibliotheque graphoque
pour moi j'utilise le TurboC3 alors le chemain hez moi est c:\tc
veillez changer chez vous
merci ;)  

Source

  • #include <graphics.h>
  • #include <ctype.h>
  • #include <stream.h>
  • #include <time.h>
  • #include <stdlib.h>
  • #include <stdio.h>
  • #include <conio.h>
  • #include <dos.h>
  • #include <string.h>
  • void boutton(int x,int y,int z,int w,int c1,int c2,int c3)
  • {
  • setfillstyle(SOLID_FILL, c3) ; bar(x,y,z,w) ;
  • setcolor(c1) ; line(x,y,z,y) ; line(x,y,x,w) ;
  • setcolor(c2) ; line(x,w,z,w) ; line(z,y,z,w) ;
  • }
  • void boutton2(int x,int y,int z,int w,int c1,int c2,int c3)
  • {
  • setfillstyle(INTERLEAVE_FILL, c3) ; bar(x,y,z,w) ;
  • setcolor(c1) ; line(x,y,z,y) ; line(x,y,x,w) ;
  • setcolor(c2) ; line(x,w,z,w) ; line(z,y,z,w) ;
  • }
  • void TabResultats()
  • {
  • boutton(200,120,574,360,15,0,7);
  • boutton(201,121,573,359,15,0,7);
  • setfillstyle(10,8);
  • bar(205,126,568,148);
  • boutton2(223,180,448,206,15,0,2);boutton(449,180,548,206,15,0,7);
  • boutton2(223,207,448,233,15,0,2);boutton(449,207,548,233,15,0,7);
  • boutton2(223,234,448,260,15,0,2);boutton(449,234,548,260,15,0,7);
  • boutton2(223,261,448,287,15,0,2);boutton(449,261,548,287,15,0,7);
  • boutton2(223,288,448,314,15,0,2);boutton(449,288,548,314,15,0,7);
  • boutton(170,362,600,420,7,7,7);
  • settextstyle(SMALL_FONT,0,4);
  • setcolor(15); outtextxy(220,132,"RESULTATS");
  • setcolor(15); outtextxy(233,188,"NOMBRE DE PROGRAMMES");
  • outtextxy(233,215,"LE TEMPS MOYENE AVANT LE CHARGEMENT");
  • outtextxy(233,242,"LE TEMPS MOYENE DE RESIDENCE");
  • outtextxy(233,269,"LE TAUX D'UTILISATION DU PROCESSEUR");
  • outtextxy(233,296,"LE TAUX D'UTILISATION DE LA MEMOIRE");
  • }
  • char *saisie(char ch[],int x,int y,int pol,int col,int esp,int plan)
  • {
  • char ch1[100],c;
  • int z=0,i=0,m=15;
  • setlinestyle(0,0,0);
  • do
  • {
  • m==15 ? m=0 : m=15 ;
  • setcolor(m);outtextxy(x+z, y+2, "_");
  • delay(100);
  • }
  • while(!kbhit());
  • c=getch();
  • while (c!=13 )
  • {
  • if( c!=8 && c!=80 && c!=72 && c!=83)
  • {
  • ch[i++]=c ;
  • sprintf(ch1, "%c",c);
  • settextstyle(SMALL_FONT, HORIZ_DIR,pol);
  • setcolor(col);outtextxy(x+z, y, ch1);
  • z+=esp;
  • setcolor(15);line(x, y+12,x+z+7,y+12);
  • setcolor(0);outtextxy(x+z, y+2, "_");
  • do
  • {
  • m==15 ? m=0 : m=15 ;
  • setcolor(m);outtextxy(x+z, y+2, "_");
  • delay(100);
  • }
  • while(!kbhit());
  • }
  • if (c==8)
  • {
  • --i;
  • z-=esp;
  • setfillstyle(SOLID_FILL,plan);
  • bar(x+z,y+2,x+z+10,y+14);
  • i<0 ? i=0 : i ;
  • z<0 ? z=0 : z ;
  • do
  • {
  • m==15 ? m=0 : m=15 ;
  • setcolor(m);outtextxy(x+z, y+2, "_");
  • delay(100);
  • }
  • while(!kbhit());
  • }
  • if(c==83)
  • {
  • setfillstyle(SOLID_FILL,plan);
  • bar(x,y+2,x+z,y+14);
  • i=0 ; z=0 ;
  • do
  • {
  • m==15 ? m=0 : m=15 ;
  • setcolor(m);outtextxy(x+z, y+2, "_");
  • delay(100);
  • }
  • while(!kbhit());
  • }
  • c=getch();
  • }
  • setcolor(15);line(x, y+12,x+z+14,y+12);
  • ch[i]='\0';
  • return ch;
  • }
  • void Interface()
  • {
  • setfillstyle(10,9);
  • bar(0,0,639,479);
  • settextstyle(TRIPLEX_FONT, 0,4);
  • setcolor(15);
  • outtextxy(64,12,"SYSTEME D'EXPLOITATION");
  • settextstyle(SMALL_FONT, 0,4);
  • setcolor(14);outtextxy(20,5,"MINI-PROJET");
  • boutton2(9,60,138,440,15,0,1);
  • boutton2(10,61,137,439,15,0,1);
  • boutton(18,69,130,434,15,0,1);
  • setfillstyle(10,8);
  • bar(24,76,122,98); setcolor(7);
  • settextstyle(SMALL_FONT, 0,5);outtextxy(53,80,"MENU");
  • boutton(24,105,124,340,0,15,1);
  • boutton2(145,60,628,440,15,0,7);
  • boutton(152,67,623,435,15,0,7);
  • boutton(160,74,614,427,0,15,7);
  • boutton(32,140,116,158,15,0,7);
  • boutton(32,178,116,196,15,0,7);
  • boutton(32,216,116,234,15,0,7);
  • boutton(32,254,116,272,15,0,7);
  • boutton(32,292,116,310,15,0,7);
  • settextstyle(SMALL_FONT, 0,4);
  • setcolor(9); outtextxy(44,143,"PARAMETRES");
  • outtextxy(52,181,"VALIDER");
  • outtextxy(52,219,"EFFACER");
  • outtextxy(46,256,"RESULTATS");
  • outtextxy(52,294,"QUITTER");
  • settextstyle(TRIPLEX_FONT, 0,4);
  • setcolor(9); outtextxy(37,376,"EMSI");
  • outtextxy(38,377,"EMSI");
  • outtextxy(39,378,"EMSI");
  • outtextxy(40,379,"EMSI");
  • setcolor(15); outtextxy(41,380,"EMSI");
  • settextstyle(SMALL_FONT, 0,4);
  • }
  • void TabGermes()
  • {
  • boutton(200,120,574,360,15,0,7);
  • boutton(201,121,573,359,15,0,7);
  • boutton(220,141,553,196,0,0,7);
  • boutton(221,142,552,195,15,15,7);
  • boutton(230,130,380,150,7,7,7);
  • setcolor(9); outtextxy(238,136,"LA TAILLE DE LA MEMOIRE");
  • boutton(260,160,360,180,15,0,7);boutton(390,160,500,180,0,8,15);
  • setcolor(9);outtextxy(280,164,"TAILLE");
  • boutton(221,205,552,350,0,0,7);
  • boutton(222,206,551,349,15,15,7);
  • boutton(231,198,304,218,7,7,7);
  • setcolor(9); outtextxy(238,200,"LES GERMES");
  • boutton2(250,234,350,254,15,0,1);
  • boutton2(351,234,405,254,15,0,1);
  • boutton2(406,234,460,254,15,0,1);
  • boutton2(461,234,521,254,15,0,1);
  • boutton2(250,255,350,275,15,0,1);
  • boutton(351,255,405,275,15,0,15);
  • boutton(406,255,460,275,15,0,15);
  • boutton(461,255,521,275,15,0,15);
  • boutton2(250,276,350,296,15,0,1);
  • boutton(351,276,405,296,15,0,15);
  • boutton(406,276,460,296,15,0,15);
  • boutton(461,276,521,296,15,0,15);
  • boutton2(250,297,350,317,15,0,1);
  • boutton(351,297,405,317,15,0,15);
  • boutton(406,297,460,317,15,0,15);
  • boutton(461,297,521,317,15,0,15);
  • setcolor(15);
  • outtextxy(260,238,"Germes");
  • outtextxy(260,259,"Arriv,e");
  • outtextxy(260,279,"Taille");
  • outtextxy(260,299,"D . d'axecution");
  • outtextxy(372,238,"Ix");
  • outtextxy(426,238,"Iy");
  • outtextxy(482,238,"Iz");
  • }
  • void ChoixMenu(int a)
  • {
  • switch(a)
  • {
  • case 1 : boutton(32,140,116,158,0,15,7);
  • setcolor(9); outtextxy(44,143,"PARAMETRES");
  • break ;
  • case 2 : boutton(32,178,116,196,0,15,7);
  • setcolor(9) ; outtextxy(52,181,"VALIDER");
  • break ;
  • case 3 : boutton(32,216,116,234,0,15,7);
  • setcolor(9) ; outtextxy(52,219,"EFFACER");
  • break ;
  • case 4 : boutton(32,254,116,272,0,15,7);
  • setcolor(9) ; outtextxy(46,256,"RESULTATS");
  • break ;
  • case 5 : boutton(32,292,116,310,0,15,7);
  • setcolor(9); outtextxy(52,294,"QUITTER");
  • break ;
  • }
  • }
  • void EffaceMenu()
  • {
  • boutton(32,140,116,158,15,0,7);
  • boutton(32,178,116,196,15,0,7);
  • boutton(32,216,116,234,15,0,7);
  • boutton(32,254,116,272,15,0,7);
  • boutton(32,292,116,310,15,0,7);
  • settextstyle(SMALL_FONT, 0,4);
  • setcolor(9); outtextxy(44,143,"PARAMETRES");
  • outtextxy(52,181,"VALIDER");
  • outtextxy(52,219,"EFFACER");
  • outtextxy(46,256,"RESULTATS");
  • outtextxy(52,294,"QUITTER");
  • }
  • int Convertion(char Chaine[])
  • {
  • int n;
  • int i;
  • int OK;
  • OK=1;
  • n=0;
  • for (i=0; OK && Chaine[i]; i++)
  • if (isdigit(Chaine[i]))
  • n = n*10 + (Chaine[i]-'0');
  • else
  • OK=0;
  • if (!OK)
  • outtextxy(30,430,"Valeur Non Num,rique");
  • return n;
  • }
  • int SaisieGermes(char ch[],int x,int y)
  • {
  • int n;
  • saisie(ch,x,y,4,9,6,15);
  • n= Convertion(ch);
  • return n;
  • }
  • void Couleurs()
  • {
  • setpalette(1,24);
  • setpalette(2,32);
  • setpalette(3,49);
  • setpalette(5,1);
  • setpalette(6,19);
  • setpalette(4,49);
  • setpalette(9,8);
  • setpalette(10,55);
  • setpalette(11,28);
  • setpalette(14,14);
  • }
  • struct Calendrier
  • {
  • int Ref;
  • char Type;
  • float Date;
  • } Arr,Fq;
  • struct memoire
  • {
  • int Ref ;
  • float Taille;
  • float DurExec;
  • float DateArri;
  • float DateCharg;
  • float FinExec;
  • } Mem[1500];
  • typedef struct File
  • {
  • int Ref;
  • struct File *suiv;
  • } TypeFile ;
  • typedef TypeFile *AdrRef;
  • int Ix1,Iy1,Iz1,Ix2,Iy2,Iz2,Ix3,Iy3,Iz3,i,d,PROC,arret,NbProg;
  • float h,MCD,processeur=0,tauxMem=0,ti=0,MemFixe;
  • AdrRef PremMem=NULL,PremProc=NULL,PrecMem,PrecProc;
  • float alea(int *Ix ,int *Iy ,int *Iz)
  • {
  • float x,y;
  • *Ix = 171 * (*Ix%177)-2 * (*Ix/177);
  • if (*Ix<0)
  • *Ix+=30269;
  • *Iy = 172 * (*Iy%176)-35 * (*Iy/176);
  • if (*Iy<0)
  • *Iy+=30307;
  • *Iz = 170 * (*Iz%178)-63 * (*Iz/178);
  • if (*Iz<0)
  • *Iz+=30323;
  • x = (float)*Ix/30269 + (float)*Iy/30307 + (float)*Iz/30323;
  • y=x-(long)x;
  • return y;
  • }
  • //************************suppression du 1 ,r prog de la liste *************
  • int defiler(AdrRef *prem)
  • {
  • int RetPrem;
  • AdrRef PremFile;
  • RetPrem=(*prem)->Ref;
  • PremFile=*prem;
  • *prem=(*prem)->suiv;
  • free(PremFile);
  • return RetPrem;
  • }
  • //****************** insertion a la fin de la liste *************************
  • void enfiler(AdrRef *prec,AdrRef *debut,int Val_Inser )
  • {
  • AdrRef nouv;
  • nouv=(AdrRef)malloc(sizeof(TypeFile));
  • nouv->Ref=Val_Inser;
  • if(*debut==NULL)
  • *debut=nouv;
  • else
  • (*prec)->suiv=nouv;
  • nouv->suiv=NULL;
  • *prec=nouv;
  • }
  • //*************************************************************************
  • float RechDuree(int Ref )
  • {
  • int z;
  • float Duree;
  • for( z=0 ; z<=d ; z++)
  • {
  • if (Mem[z].Ref ==Ref)
  • Duree= Mem[z].DurExec;
  • }
  • return Duree;
  • }
  • //*************** la recherche de la taille ********************************
  • float RechTaille(int Ref)
  • {
  • int z;
  • float taille;
  • for(z=0;z<=d;z++)
  • {
  • if (Mem[z].Ref ==Ref )
  • taille= Mem[z].Taille;
  • }
  • return taille;
  • }
  • //*************** modification de la duree ************************************
  • void ModifDuree(int Ref,float Qtum )
  • {
  • int z;
  • for( z=0;z<=d;z++)
  • {
  • if( Mem[z].Ref==Ref)
  • Mem[z].DurExec-=Qtum;
  • }
  • }
  • //*************** enregistrement de la taille ************************************
  • void InserTaille(int *Ref,float *tail)
  • {
  • int z;
  • for( z=0;z<=d;z++)
  • {
  • if( Mem[z].Ref == *Ref )
  • Mem[z].Taille = *tail ;
  • }
  • }
  • //*************** enregistrement de la duree ************************************
  • void InserDuree(int *Ref,float *dure)
  • {
  • int z;
  • for( z=0;z<=d;z++)
  • {
  • if( Mem[z].Ref== *Ref )
  • Mem[z].DurExec = *dure ;
  • }
  • }
  • //*************** enregistrement de la duree ************************************
  • void DateArrive(int *Ref,float *dateArr)
  • {
  • int z;
  • for ( z=0;z<=d;z++)
  • {
  • if( Mem[z].Ref == *Ref)
  • Mem[z].DateArri = *dateArr;
  • }
  • }
  • //*************** enregistrement de la date de fin d'execution ************************************
  • void DateFinExec(int *Ref,float *DateFin)
  • {
  • int z;
  • for ( z=0;z<=d;z++)
  • {
  • if( Mem[z].Ref== *Ref )
  • Mem[z].FinExec = *DateFin ;
  • }
  • }
  • //*************** enregistrement de la date du chargement ************************************
  • void DateCharge(int *Ref,float *DateCharg)
  • {
  • int z;
  • for( z=0;z<=d;z++)
  • {
  • if( Mem[z].Ref== *Ref )
  • Mem[z].DateCharg = *DateCharg;
  • }
  • }
  • //*************** enregistrement de la reference *************************
  • void InserRef(int *Ref)
  • {
  • Mem[*Ref-1].Ref = *Ref ;
  • }
  • //********************PROCEDURE_ARRIVEE***********************************
  • void Arrivee()
  • {
  • float taille,duree,ArriProg;
  • taille = alea(&Ix2,&Iy2,&Iz2)*(80-5) + 5 ;
  • duree = alea(&Ix3,&Iy3,&Iz3)*(50-13)+13 ;
  • InserTaille(&Arr.Ref,&taille);
  • InserDuree(&Arr.Ref,&duree);
  • if ( PremMem==NULL && MCD>=taille )
  • {
  • MCD-=taille;
  • tauxMem+=(h-ti)*(MemFixe-MCD)/1000;
  • ti=h;
  • DateCharge(&Arr.Ref,&h);
  • if ( PremProc==NULL && PROC==0 )
  • {
  • Fq.Ref=i;
  • Fq.Type='F';
  • Fq.Date=h+3;
  • enfiler(&PrecProc,&PremProc,Fq.Ref );
  • processeur=processeur +3;
  • ModifDuree(Fq.Ref,3);
  • PROC=1;
  • }
  • else
  • enfiler(&PrecProc,&PremProc,Arr.Ref );
  • }
  • else
  • enfiler(&PrecMem,&PremMem,Arr.Ref );
  • ArriProg= alea(&Ix1,&Iy1,&Iz1)*(52-10)+10 ;
  • d++;
  • if (ArriProg+h<=43200)
  • {
  • i+=1;
  • Arr.Ref=i;
  • Arr.Type='A';
  • Arr.Date= h + ArriProg;
  • InserRef(&i);
  • DateArrive(&Arr.Ref,&Arr.Date);
  • }
  • else
  • {
  • d--;
  • NbProg=Arr.Ref;
  • Arr.Date=50000;
  • Arr.Ref=-1;
  • }
  • }
  • //********************PROCEDURE_FIN_QUANTUM**********************************
  • void FinQuantum()
  • {
  • float Q,duree,taille ;
  • int Ref;
  • duree=RechDuree(Fq.Ref);
  • taille=RechTaille(Fq.Ref);
  • if ( duree==0)
  • {
  • PROC=0;
  • MCD+=taille;
  • tauxMem+=(h-ti)*(MemFixe-MCD)/1000;
  • ti=h;
  • Ref=defiler(&PremProc);
  • DateFinExec(&Ref,&h);
  • Fq.Ref=0;
  • if (PremMem!=NULL)
  • {
  • Ref=PremMem->Ref;
  • taille=RechTaille(Ref);
  • }
  • while ((PremMem!=NULL)&&((taille)<=MCD))
  • {
  • MCD-=taille;
  • DateCharge(&Ref,&h);
  • Ref=defiler(&PremMem);
  • enfiler(&PrecProc,&PremProc,Ref);
  • Ref=PremMem->Ref;
  • taille=RechTaille(Ref);
  • }
  • }
  • else
  • {
  • Ref=defiler(&PremProc);
  • enfiler(&PrecProc,&PremProc,Ref);
  • PROC=0;
  • }
  • if ( PremProc!=NULL)
  • {
  • Ref=PremProc->Ref;
  • duree=RechDuree(Ref);
  • if ( duree>=3 )
  • {
  • Q=3;
  • processeur+=3;
  • }
  • else
  • {
  • Q=duree;
  • processeur+=duree;
  • }
  • ModifDuree(Ref,Q);
  • Fq.Ref=Ref;
  • Fq.Type='F';
  • Fq.Date=h+Q;
  • PROC=1;
  • }
  • }
  • void Menu()
  • {
  • char Ch[10];
  • char ch[10];
  • float somme,somme1,ArriProg;
  • float x,y,z,w;
  • char k;
  • int m=1;
  • int t=0;
  • while (m!=0)
  • {
  • k=getch();
  • switch(k)
  • {
  • case 72 :
  • case 75 : EffaceMenu();
  • t-- ; if(t<1) t=5 ; ChoixMenu(t) ;
  • break ;
  • case 80 :
  • case 77 : EffaceMenu() ;
  • t++ ; if(t>5) t=1 ; ChoixMenu(t) ;
  • break ;
  • case 13 : switch(t)
  • {
  • case 1 : PROC=0;h=0;i=1;arret=0;somme=0,somme1=0;
  • Fq.Ref=0;Fq.Type='0';Fq.Date=0;
  • Arr.Ref=0;Arr.Type='0';Arr.Date=0;
  • processeur=0;
  • tauxMem=0,ti=0;
  • d=0;
  • TabGermes() ;
  • MCD= SaisieGermes(Ch,420,165);
  • MemFixe=MCD;
  • Ix1= SaisieGermes(Ch,361,260);
  • Iy1= SaisieGermes(Ch,414,260);
  • Iz1= SaisieGermes(Ch,468,260);
  • Ix2= SaisieGermes(Ch,361,281);
  • Iy2= SaisieGermes(Ch,414,281);
  • Iz2= SaisieGermes(Ch,468,281);
  • Ix3= SaisieGermes(Ch,361,302);
  • Iy3= SaisieGermes(Ch,414,302);
  • Iz3= SaisieGermes(Ch,468,302);
  • break ;
  • case 2 : ArriProg=(alea(&Ix1,&Iy1,&Iz1)*(52-10)+10) ;
  • Arr.Ref=i;
  • Arr.Type='A';
  • Arr.Date=ArriProg ;
  • InserRef(&Arr.Ref );
  • DateArrive(&Arr.Ref,&Arr.Date);
  • //*************************************
  • while (!((PremProc==NULL)&&(PremMem==NULL)&&(Arr.Ref==-1)))
  • {
  • if ( Arr.Date >= Fq.Date && Fq.Ref >0)
  • {
  • h=Fq.Date;
  • FinQuantum();
  • }
  • else
  • if (Arr.Ref>0)
  • {
  • h=Arr.Date;
  • Arrivee();
  • }
  • }
  • settextstyle(TRIPLEX_FONT,0,3);
  • outtextxy(200,380,"Fin D'Execution");
  • //*************************************
  • break ;
  • case 3 : TabGermes(); break ;
  • case 4 : for (i=0;i<NbProg;i++)
  • {
  • somme = somme + (Mem[i].FinExec - Mem[i].DateArri) ;
  • somme1 = somme1 + Mem[i].DateCharg - Mem[i].DateArri ;
  • }
  • x=(float)(somme1/NbProg);
  • y=(float)(processeur/h)*100;
  • z=(float)(somme/NbProg);
  • w=(float)(tauxMem/h)*100;
  • TabResultats();
  • settextstyle(SMALL_FONT,0,4);
  • sprintf(ch,"%d",NbProg);
  • setcolor(9);outtextxy(470,188,ch);
  • sprintf(ch,"%2f",x);
  • setcolor(9);outtextxy(470,212,ch);
  • sprintf(ch,"%2f",z);
  • setcolor(9);outtextxy(470,238,ch);
  • sprintf(ch,"%2f",y);
  • setcolor(9);outtextxy(470,264,ch);
  • sprintf(ch,"%2f",w);
  • setcolor(9);outtextxy(470,290,ch);
  • break ;
  • case 5 : m=0; break ;
  • }
  • break ;
  • }
  • }
  • }
  • void main()
  • {
  • int gdriver = DETECT, gmode;
  • initgraph(&gdriver, &gmode, "c:\\tc");
  • Couleurs();
  • Interface();
  • Menu();
  • closegraph();
  • }
#include <graphics.h>
#include <ctype.h>
#include <stream.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <string.h>

void boutton(int x,int y,int z,int w,int c1,int c2,int c3)
 {
  setfillstyle(SOLID_FILL, c3) ;    bar(x,y,z,w) ;
  setcolor(c1) ; line(x,y,z,y) ;    line(x,y,x,w) ;
  setcolor(c2) ; line(x,w,z,w) ;    line(z,y,z,w) ;
 }

void boutton2(int x,int y,int z,int w,int c1,int c2,int c3)
 {
  setfillstyle(INTERLEAVE_FILL, c3) ;    bar(x,y,z,w) ;
  setcolor(c1) ; line(x,y,z,y) ;    line(x,y,x,w) ;
  setcolor(c2) ; line(x,w,z,w) ;    line(z,y,z,w) ;
 }

void TabResultats()
 {
   boutton(200,120,574,360,15,0,7);
   boutton(201,121,573,359,15,0,7);
   setfillstyle(10,8);
   bar(205,126,568,148);

   boutton2(223,180,448,206,15,0,2);boutton(449,180,548,206,15,0,7);
   boutton2(223,207,448,233,15,0,2);boutton(449,207,548,233,15,0,7);
   boutton2(223,234,448,260,15,0,2);boutton(449,234,548,260,15,0,7);
   boutton2(223,261,448,287,15,0,2);boutton(449,261,548,287,15,0,7);
   boutton2(223,288,448,314,15,0,2);boutton(449,288,548,314,15,0,7);
   boutton(170,362,600,420,7,7,7);
   settextstyle(SMALL_FONT,0,4);
   setcolor(15); outtextxy(220,132,"RESULTATS");
   setcolor(15); outtextxy(233,188,"NOMBRE DE PROGRAMMES");
		outtextxy(233,215,"LE TEMPS MOYENE AVANT LE CHARGEMENT");
		outtextxy(233,242,"LE TEMPS MOYENE DE RESIDENCE");
		outtextxy(233,269,"LE TAUX D'UTILISATION DU PROCESSEUR");
		outtextxy(233,296,"LE TAUX D'UTILISATION DE LA MEMOIRE");

 }

char *saisie(char ch[],int x,int y,int pol,int col,int esp,int plan)
 {
   char ch1[100],c;
   int z=0,i=0,m=15;
   setlinestyle(0,0,0);
    do
      {
	m==15 ? m=0 : m=15 ;
	setcolor(m);outtextxy(x+z, y+2, "_");
	delay(100);
      }
    while(!kbhit());

    c=getch();
    while (c!=13 )
	{
	  if( c!=8 && c!=80 && c!=72 && c!=83)
	    {
	      ch[i++]=c ;
	      sprintf(ch1, "%c",c);
	      settextstyle(SMALL_FONT, HORIZ_DIR,pol);
	      setcolor(col);outtextxy(x+z, y, ch1);
	      z+=esp;
	      setcolor(15);line(x, y+12,x+z+7,y+12);
	      setcolor(0);outtextxy(x+z, y+2, "_");
	      do
		{
		  m==15 ? m=0 : m=15 ;
		  setcolor(m);outtextxy(x+z, y+2, "_");
		  delay(100);
		}
	      while(!kbhit());
	    }

	  if (c==8)
	      {
		--i;
		z-=esp;
		setfillstyle(SOLID_FILL,plan);
		bar(x+z,y+2,x+z+10,y+14);
		i<0 ? i=0 : i ;
		z<0 ? z=0 : z ;
		 do
		  {
		   m==15 ? m=0 : m=15 ;
		    setcolor(m);outtextxy(x+z, y+2, "_");
		    delay(100);
		  }
		 while(!kbhit());
	      }

	  if(c==83)
	    {
	      setfillstyle(SOLID_FILL,plan);
	      bar(x,y+2,x+z,y+14);
	      i=0 ; z=0 ;
	       do
		{
		  m==15 ? m=0 : m=15 ;
		  setcolor(m);outtextxy(x+z, y+2, "_");
		  delay(100);
		}
	       while(!kbhit());
	    }
	 c=getch();
	}

    setcolor(15);line(x, y+12,x+z+14,y+12);
    ch[i]='\0';
    return ch;
 }

void Interface()
 {

   setfillstyle(10,9);
   bar(0,0,639,479);
     settextstyle(TRIPLEX_FONT, 0,4);
     setcolor(15);
     outtextxy(64,12,"SYSTEME D'EXPLOITATION");
   settextstyle(SMALL_FONT, 0,4);
   setcolor(14);outtextxy(20,5,"MINI-PROJET");
   boutton2(9,60,138,440,15,0,1);
   boutton2(10,61,137,439,15,0,1);
   boutton(18,69,130,434,15,0,1);
   setfillstyle(10,8);
   bar(24,76,122,98); setcolor(7);
   settextstyle(SMALL_FONT, 0,5);outtextxy(53,80,"MENU");
   boutton(24,105,124,340,0,15,1);

   boutton2(145,60,628,440,15,0,7);
   boutton(152,67,623,435,15,0,7);
   boutton(160,74,614,427,0,15,7);


   boutton(32,140,116,158,15,0,7);
   boutton(32,178,116,196,15,0,7);
   boutton(32,216,116,234,15,0,7);
   boutton(32,254,116,272,15,0,7);
   boutton(32,292,116,310,15,0,7);
   settextstyle(SMALL_FONT, 0,4);
   setcolor(9); outtextxy(44,143,"PARAMETRES");
		outtextxy(52,181,"VALIDER");
		outtextxy(52,219,"EFFACER");
		outtextxy(46,256,"RESULTATS");
		outtextxy(52,294,"QUITTER");

   settextstyle(TRIPLEX_FONT, 0,4);
   setcolor(9);       outtextxy(37,376,"EMSI");
		      outtextxy(38,377,"EMSI");
		      outtextxy(39,378,"EMSI");
		      outtextxy(40,379,"EMSI");
   setcolor(15);      outtextxy(41,380,"EMSI");
   settextstyle(SMALL_FONT, 0,4);
 }

void TabGermes()
 {
   boutton(200,120,574,360,15,0,7);
   boutton(201,121,573,359,15,0,7);
   boutton(220,141,553,196,0,0,7);
   boutton(221,142,552,195,15,15,7);
   boutton(230,130,380,150,7,7,7);
   setcolor(9); outtextxy(238,136,"LA TAILLE DE LA MEMOIRE");

   boutton(260,160,360,180,15,0,7);boutton(390,160,500,180,0,8,15);
   setcolor(9);outtextxy(280,164,"TAILLE");
   boutton(221,205,552,350,0,0,7);
   boutton(222,206,551,349,15,15,7);
   boutton(231,198,304,218,7,7,7);

   setcolor(9); outtextxy(238,200,"LES GERMES");

   boutton2(250,234,350,254,15,0,1);
   boutton2(351,234,405,254,15,0,1);
   boutton2(406,234,460,254,15,0,1);
   boutton2(461,234,521,254,15,0,1);

   boutton2(250,255,350,275,15,0,1);
   boutton(351,255,405,275,15,0,15);
   boutton(406,255,460,275,15,0,15);
   boutton(461,255,521,275,15,0,15);

   boutton2(250,276,350,296,15,0,1);
   boutton(351,276,405,296,15,0,15);
   boutton(406,276,460,296,15,0,15);
   boutton(461,276,521,296,15,0,15);

   boutton2(250,297,350,317,15,0,1);
   boutton(351,297,405,317,15,0,15);
   boutton(406,297,460,317,15,0,15);
   boutton(461,297,521,317,15,0,15);

   setcolor(15);
   outtextxy(260,238,"Germes");
   outtextxy(260,259,"Arriv,e");
   outtextxy(260,279,"Taille");
   outtextxy(260,299,"D . d'axecution");
   outtextxy(372,238,"Ix");
   outtextxy(426,238,"Iy");
   outtextxy(482,238,"Iz");
 }

void ChoixMenu(int a)
 {
  switch(a)
    {
      case 1 : boutton(32,140,116,158,0,15,7);
	       setcolor(9); outtextxy(44,143,"PARAMETRES");
	       break ;
      case 2 : boutton(32,178,116,196,0,15,7);
	       setcolor(9) ; outtextxy(52,181,"VALIDER");
	       break ;
      case 3 : boutton(32,216,116,234,0,15,7);
	       setcolor(9) ; outtextxy(52,219,"EFFACER");
	       break ;
      case 4 : boutton(32,254,116,272,0,15,7);
	       setcolor(9) ; 	outtextxy(46,256,"RESULTATS");
	       break ;
      case 5 : boutton(32,292,116,310,0,15,7);
	       setcolor(9); outtextxy(52,294,"QUITTER");
	       break ;
    }
 }

void EffaceMenu()
 {
   boutton(32,140,116,158,15,0,7);
   boutton(32,178,116,196,15,0,7);
   boutton(32,216,116,234,15,0,7);
   boutton(32,254,116,272,15,0,7);
   boutton(32,292,116,310,15,0,7);
   settextstyle(SMALL_FONT, 0,4);
   setcolor(9); outtextxy(44,143,"PARAMETRES");
		outtextxy(52,181,"VALIDER");
		outtextxy(52,219,"EFFACER");
		outtextxy(46,256,"RESULTATS");
		outtextxy(52,294,"QUITTER");
 }

int Convertion(char Chaine[])
 {
   int n;
   int i;
   int OK;

   OK=1;
   n=0;
   for (i=0; OK && Chaine[i]; i++)
     if (isdigit(Chaine[i]))
	n = n*10 + (Chaine[i]-'0');
     else
	OK=0;
   if (!OK)
      outtextxy(30,430,"Valeur Non Num,rique");

   return n;
 }

int SaisieGermes(char ch[],int x,int y)
 {
  int n;
  saisie(ch,x,y,4,9,6,15);
  n= Convertion(ch);
  return n;
 }


void Couleurs()
 {
   setpalette(1,24);
   setpalette(2,32);
   setpalette(3,49);
   setpalette(5,1);
   setpalette(6,19);
   setpalette(4,49);
   setpalette(9,8);
   setpalette(10,55);
   setpalette(11,28);
   setpalette(14,14);
 }


struct Calendrier
       {
	 int    Ref;
	 char   Type;
	 float  Date;
       } Arr,Fq;

struct   memoire
	{
	 int     Ref ;
	 float   Taille;
	 float   DurExec;
	 float   DateArri;
	 float   DateCharg;
	 float   FinExec;
	 } Mem[1500];

typedef struct File
		     {
		       int Ref;
		       struct File *suiv;
		     } TypeFile ;

typedef TypeFile *AdrRef;

int Ix1,Iy1,Iz1,Ix2,Iy2,Iz2,Ix3,Iy3,Iz3,i,d,PROC,arret,NbProg;
float   h,MCD,processeur=0,tauxMem=0,ti=0,MemFixe;



AdrRef PremMem=NULL,PremProc=NULL,PrecMem,PrecProc;

float alea(int  *Ix ,int  *Iy ,int  *Iz)
 {
   float  x,y;

       *Ix = 171 * (*Ix%177)-2 * (*Ix/177);
       if (*Ix<0)
		  *Ix+=30269;

	*Iy = 172 * (*Iy%176)-35 * (*Iy/176);
       if (*Iy<0)
		  *Iy+=30307;

       *Iz = 170 * (*Iz%178)-63 * (*Iz/178);
       if (*Iz<0)
		  *Iz+=30323;

  x = (float)*Ix/30269 + (float)*Iy/30307 + (float)*Iz/30323;
  y=x-(long)x;
  return y;
 }

//************************suppression du 1 ,r prog de la liste *************

int defiler(AdrRef *prem)
 {
  int RetPrem;
  AdrRef PremFile;

  RetPrem=(*prem)->Ref;
  PremFile=*prem;
  *prem=(*prem)->suiv;
  free(PremFile);
  return RetPrem;
 }

//****************** insertion a la fin de la liste *************************

 void enfiler(AdrRef *prec,AdrRef *debut,int Val_Inser )
      {
	AdrRef nouv;
	nouv=(AdrRef)malloc(sizeof(TypeFile));
	nouv->Ref=Val_Inser;
	if(*debut==NULL)
	     *debut=nouv;
	else
	     (*prec)->suiv=nouv;
	nouv->suiv=NULL;

	*prec=nouv;
       }

//*************************************************************************

float RechDuree(int Ref )
 {
  int z;
  float Duree;
  for( z=0 ; z<=d ; z++)
      {
	 if (Mem[z].Ref ==Ref)
	    Duree= Mem[z].DurExec;
      }
 return  Duree;
}

//*************** la recherche de la taille ********************************

float RechTaille(int Ref)
 {
   int z;
   float taille;

   for(z=0;z<=d;z++)
      {
	 if (Mem[z].Ref ==Ref )
	 taille= Mem[z].Taille;
      }
   return taille;
 }

//*************** modification de la duree ************************************

void ModifDuree(int Ref,float Qtum )
 {
   int z;
   for( z=0;z<=d;z++)
	 {
	  if( Mem[z].Ref==Ref)
	  Mem[z].DurExec-=Qtum;
	 }
}

//*************** enregistrement de la taille ************************************

void InserTaille(int *Ref,float *tail)
 {
   int z;
   for( z=0;z<=d;z++)
	 {
	  if( Mem[z].Ref == *Ref )
	      Mem[z].Taille = *tail ;
	 }
 }

//*************** enregistrement de la duree ************************************

void InserDuree(int *Ref,float *dure)
 {
   int z;
   for( z=0;z<=d;z++)
	 {
	  if( Mem[z].Ref== *Ref )
	  Mem[z].DurExec = *dure ;
	 }
 }

//*************** enregistrement de la duree ************************************

void DateArrive(int *Ref,float *dateArr)
 {
   int z;
   for ( z=0;z<=d;z++)
      {
	 if( Mem[z].Ref == *Ref)
	  Mem[z].DateArri = *dateArr;
      }
}

//*************** enregistrement de la date de fin d'execution ************************************

void DateFinExec(int *Ref,float *DateFin)
 {
   int z;
   for ( z=0;z<=d;z++)
      {
	if( Mem[z].Ref== *Ref )
	  Mem[z].FinExec = *DateFin ;
      }
 }

//*************** enregistrement de la date du chargement ************************************

void DateCharge(int *Ref,float *DateCharg)
 {
   int z;
   for( z=0;z<=d;z++)
	 {
	  if( Mem[z].Ref== *Ref )
	    Mem[z].DateCharg = *DateCharg;
	 }
 }

//*************** enregistrement de la reference *************************

void InserRef(int *Ref)
 {
   Mem[*Ref-1].Ref = *Ref ;
 }

//********************PROCEDURE_ARRIVEE***********************************
void Arrivee()
 {
   float taille,duree,ArriProg;
   taille = alea(&Ix2,&Iy2,&Iz2)*(80-5) + 5 ;
   duree  = alea(&Ix3,&Iy3,&Iz3)*(50-13)+13 ;
   InserTaille(&Arr.Ref,&taille);
   InserDuree(&Arr.Ref,&duree);

   if ( PremMem==NULL && MCD>=taille )
     {

       MCD-=taille;
       tauxMem+=(h-ti)*(MemFixe-MCD)/1000;
       ti=h;
       DateCharge(&Arr.Ref,&h);
	  if ( PremProc==NULL && PROC==0 )
	    {
	      Fq.Ref=i;
	      Fq.Type='F';
	      Fq.Date=h+3;
	      enfiler(&PrecProc,&PremProc,Fq.Ref );
	      processeur=processeur +3;
	      ModifDuree(Fq.Ref,3);
	      PROC=1;
	    }
	 else
	    enfiler(&PrecProc,&PremProc,Arr.Ref );
	}
else
  enfiler(&PrecMem,&PremMem,Arr.Ref );

  ArriProg= alea(&Ix1,&Iy1,&Iz1)*(52-10)+10 ;
  d++;
  if (ArriProg+h<=43200)
	 {
	   i+=1;
	   Arr.Ref=i;
	   Arr.Type='A';
	   Arr.Date= h + ArriProg;
	   InserRef(&i);
	   DateArrive(&Arr.Ref,&Arr.Date);
	 }
  else
	 {
	   d--;
	   NbProg=Arr.Ref;
	   Arr.Date=50000;
	   Arr.Ref=-1;
	 }
}

//********************PROCEDURE_FIN_QUANTUM**********************************

void FinQuantum()
 {
   float Q,duree,taille ;
   int Ref;
   duree=RechDuree(Fq.Ref);
   taille=RechTaille(Fq.Ref);
   if ( duree==0)
     {
       PROC=0;
       MCD+=taille;
       tauxMem+=(h-ti)*(MemFixe-MCD)/1000;
       ti=h;
       Ref=defiler(&PremProc);
       DateFinExec(&Ref,&h);
       Fq.Ref=0;
       if (PremMem!=NULL)
	 {
	    Ref=PremMem->Ref;
	    taille=RechTaille(Ref);
	 }
       while ((PremMem!=NULL)&&((taille)<=MCD))
	    {
	       MCD-=taille;
	       DateCharge(&Ref,&h);
	       Ref=defiler(&PremMem);
	       enfiler(&PrecProc,&PremProc,Ref);
	       Ref=PremMem->Ref;
	       taille=RechTaille(Ref);
	     }
     }
    else
      {
	Ref=defiler(&PremProc);
	enfiler(&PrecProc,&PremProc,Ref);
	PROC=0;
      }

    if ( PremProc!=NULL)
      {
	 Ref=PremProc->Ref;
	 duree=RechDuree(Ref);
	 if ( duree>=3 )
	   {
	     Q=3;

	     processeur+=3;
	   }
	  else
	    {
	      Q=duree;
	      processeur+=duree;
	    }
	  ModifDuree(Ref,Q);

	Fq.Ref=Ref;
	Fq.Type='F';
	Fq.Date=h+Q;
	PROC=1;
      }
 }


void Menu()
 {
   char Ch[10];
   char ch[10];
   float somme,somme1,ArriProg;

   float x,y,z,w;

   char k;
   int m=1;
   int t=0;

   while (m!=0)
     {
       k=getch();
       switch(k)
	 {
	   case 72 :
	   case 75 :   EffaceMenu();
		       t-- ; if(t<1)  t=5 ; ChoixMenu(t) ;
		       break ;

	   case 80 :
	   case 77 :   EffaceMenu() ;
		       t++ ; if(t>5) t=1 ;  ChoixMenu(t) ;
		       break ;
	   case 13 :   switch(t)
			 {
			   case 1 : PROC=0;h=0;i=1;arret=0;somme=0,somme1=0;
				    Fq.Ref=0;Fq.Type='0';Fq.Date=0;
				    Arr.Ref=0;Arr.Type='0';Arr.Date=0;
				    processeur=0;
				    tauxMem=0,ti=0;
				    d=0;
				    TabGermes() ;
				    MCD= SaisieGermes(Ch,420,165);
				    MemFixe=MCD;
				    Ix1= SaisieGermes(Ch,361,260);
				    Iy1= SaisieGermes(Ch,414,260);
				    Iz1= SaisieGermes(Ch,468,260);
				    Ix2= SaisieGermes(Ch,361,281);
				    Iy2= SaisieGermes(Ch,414,281);
				    Iz2= SaisieGermes(Ch,468,281);
				    Ix3= SaisieGermes(Ch,361,302);
				    Iy3= SaisieGermes(Ch,414,302);
				    Iz3= SaisieGermes(Ch,468,302);
				    break ;
			   case 2 : ArriProg=(alea(&Ix1,&Iy1,&Iz1)*(52-10)+10) ;
				    Arr.Ref=i;
				    Arr.Type='A';
				    Arr.Date=ArriProg ;
				    InserRef(&Arr.Ref );
				    DateArrive(&Arr.Ref,&Arr.Date);

				    //*************************************

				    while (!((PremProc==NULL)&&(PremMem==NULL)&&(Arr.Ref==-1)))
					 {
					   if ( Arr.Date >= Fq.Date && Fq.Ref >0)
					     {
					       h=Fq.Date;
					       FinQuantum();
					     }
					   else
					   if (Arr.Ref>0)
					     {
					       h=Arr.Date;
					       Arrivee();
					     }
					 }

				    settextstyle(TRIPLEX_FONT,0,3);
				    outtextxy(200,380,"Fin D'Execution");
				   //*************************************

				    break ;
			   case 3 : TabGermes(); break ;
			   case 4 : for (i=0;i<NbProg;i++)
				       {
					somme  =  somme + (Mem[i].FinExec - Mem[i].DateArri) ;
					somme1 = somme1 + Mem[i].DateCharg - Mem[i].DateArri ;
				       }
				    x=(float)(somme1/NbProg);
				    y=(float)(processeur/h)*100;
				    z=(float)(somme/NbProg);
				    w=(float)(tauxMem/h)*100;
				    TabResultats();
				    settextstyle(SMALL_FONT,0,4);
				    sprintf(ch,"%d",NbProg);
				    setcolor(9);outtextxy(470,188,ch);
				    sprintf(ch,"%2f",x);
				    setcolor(9);outtextxy(470,212,ch);
				    sprintf(ch,"%2f",z);
				    setcolor(9);outtextxy(470,238,ch);
				    sprintf(ch,"%2f",y);
				    setcolor(9);outtextxy(470,264,ch);
				    sprintf(ch,"%2f",w);

				    setcolor(9);outtextxy(470,290,ch);

				    break ;
			   case 5 : m=0; break ;
			 }
	   break ;

	 }
     }
 }

void main()
 {
   int  gdriver = DETECT, gmode;
   initgraph(&gdriver, &gmode, "c:\\tc");

   Couleurs();
   Interface();
   Menu();
   closegraph();
 }

  



 Sources du même auteur

Source avec Zip CALCULATRICE SCIENTIFIQUE AVEC LE LIBELLE VERSION 2
Source avec Zip CALCULATRICE EN VISUAL C++ EN ATTANDANT DES AMÉLIORATION
Source avec une capture CONVERTISSEUR DE CHIFFRES ROMAIN AU CHIFFRE DÉCIMALE
MENU DEROULANT ANSI C
LA RESOLUTION D'UN SYSTEM AVEC LA METHODE DE GAUSSE ET NEWTO...

 Sources de la même categorie

Source avec Zip Source avec une capture INFORMATION PROCESSEUR (CPUID) par Devils_Tiger
Source avec Zip Source avec une capture LECTURE TEMPÉRATURE PROCESSEUR par Devils_Tiger
Source avec Zip Source avec une capture LECTURE FRÉQUENCE PROCESSEUR par Devils_Tiger
Source avec Zip Source avec une capture UNE LISTE HÉTÉROGÈNE DOUBLEMENT CHAINÉE par pgl10
Source avec Zip Source avec une capture POUR AFFICHER LES CARACTÈRES ACCENTUÉS SOUS WINDOWS EN MODE ... par pgl10

Commentaires et avis

Commentaire de casanovasimo le 22/05/2007 15:04:23

je suis aussi un étudiant de l'EMSI tré cool ton programe

Commentaire de hamdan le 22/05/2007 16:05:25

bon courage alors

Commentaire de casanovasimo le 26/05/2007 00:55:41

g le mém mini proger cétt année mé moin compliquer ca conssiste a réaliser graphiquement la pagination simple avec des 30page dune taille fix=100 ke je doit réaliser
mai le tien est bien plu détaillé bravo continu comm ca et bon courage a toi aussi

Commentaire de hamdan le 27/05/2007 00:21:22

j'ai fini mes études ça fait 4 ans a l'emsi Rabat
j'ai eu deux mastère de l'INSA de Lyon
et mtn je suis ingénieur études et developpement R&D dans une SSI a Rabat
a toi tout le courage amigo

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,390 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales