developing code with threadswriting code to


Developing Code with Threads

Writing code to support a thread-based implementation is very straightforward. Simple APIs are presented to the developer for each threads package. Actually, there are striking similarities between thread implementations on NetWare, Windows NT, and OS/2. We will use the Worker Model example of threads implementation introduced in the previous section. This example will be extended to include specifics for creating, controlling, and exiting threads for each platform. Listing shows the pseudocode representation of our example. We will only modify commands relating to threads in this example. Those commands will be highlighted and all other pseudocode will be left as-is.

LISTING

AcceptRegistrationRequests()

{

 do {

  .......

  WaitForClientRequestration( )

  RegisterClient()

  RegisterAsUser

  StartWorkerThread ()

           .......

  } while (FOREVER)

    }

    WorkerThread()

     {

    do {

  WaitForInterval ()

    if (CheckForWorkRequest() )  {

         Process Request ( )

         Send Response ( )

  }

     } while(CLIENT_CONNECTED)

     LeaveThread( )

}

Request for Solution File

Ask an Expert for Answer!!
Operating System: developing code with threadswriting code to
Reference No:- TGS0289620

Expected delivery within 24 Hours