.


:




:

































 

 

 

 





 

. OS, API- .

class OS {

OS() {...};

public int CreateProcess(int ProcType, int baseprior)

{

...

return pid;

}

public void MyResume(int pid) {

...

}

public void MySuspend(int pid){

...

}...

}

 

}

OS , . , , : . , , :

class Description {

int pid; //

int state; //

int prior; //

MyProcess context; //

...

}

 

, Collection List, ArrayList.

. , , , , API- .

, :

class NTimerThread implements Runnable{

Thread t;

 

NTimerThread () //

{

t = new Thread(this); //

t.start(); //

}

 

public void run() // ,

//

{

try

{

while (true) //

{

Date d=new Date(); //

System.out.println(d.toString()); //

//

Thread.sleep(1000); //

//,

//

//

}

} catch (InterruptedException e) {

System.out.println("Thread");

}

}

};

. . , 0.2 - :

while (true) //

{

Random rand= new Random();

Date d=new Date(); //

System.out.println(d.toString()); //

//

Thread.sleep(1000); //

//,

//

//

if (rand.nextDouble()<0.2) os.myterminate(pid);

// 0.2 //API

}

os - OS, pid - . , , , " ()":

abstract class MyProcess implements Runnable

{

int pid;

Thread t;

...

public void resume()

{

t.start();

}

public void suspend()

{

t.suspend();

}

public void terminate()

{

t.stop();

}

...

 

}

 

,

class NThread extends MyProcess implements Runnable{

 

OS os;

 

NThread (OS myos, int apid){

os=myos;

pid=apid;

t = new Thread(this);

...

}

. , void MainKernel (), . . . mainkernel:

1) , ;

2) . MyProcess.resume();

3) ( Threed.sleep() );

4) , MyProcess.suspend();

5) . .

6) , . .1.

 

. , , .

, , , . , (System.out.println()).

1.3

 

. , , :

1) : exec T P, T - , P - (, exec 1 6).

2) : kill PID, PID - .

3) : ps.

, , ..

 





:


: 2016-11-12; !; : 396 |


:

:

: , .
==> ...

1487 - | 1462 -


© 2015-2024 lektsii.org - -

: 0.012 .