Define the os/2 threads code, Operating System

Assignment Help:

Define the OS/2 threads code

The sample program in Listing is very similar to the NetWare example. OS/2 commands are substituted for the pseudocode commands controlling thread creation and execution.

Listing

Void WorkerThread(ULONG userID);

#define SLEEP_INTERVAL (ULONG) 50

void AcceptRegisterationRequests( )

{

   int userID, threadID ;

   do{

        ......

        WaitforClientRegistration( )

        RegisterClient()

        UserID = RegisterAsUser ( )

        DocCreateThread(&threadID,WorkerThread, userID, 0, 8192)

        ......

     } while (FOREVER)

   }

   Void WorkerThread(ULONG userID);

   {

  do{

          DosSleep(SLEEP_INTERVAL);

                   if (WorkAvailable) {

    Process Request ( )

    Send Response ( )

   }

  } while (CLENT_CONNECTED)

  DosExit(EXIT_THREAD,0);

 }

Listing : OS/2 threads code example  Upon successful registration, an OS/2 thread is started with the CreateThread(  ) command. The function WorkerThread( ) begins asynchronous execution and loops at specified intervals looking for work to perform. The intervals are created by the DosSleep ( ) function call and  will allow  the thread to periodically  poll for available work.When the client requests closure of the connection or an error occurs, the DosExit( ) function will be performed to exit the current worker thread.


Related Discussions:- Define the os/2 threads code

What is symmetric multiprocessing, Symmetric multiprocessing To get ma...

Symmetric multiprocessing To get maximum reliability and efficiency a mode of function called as symmetric multiprocessing is used. In essence, with SMP any program or threads

Define seek time and latency time, Define seek time and latency time. T...

Define seek time and latency time. The time taken by the head to move to the appropriate cylinder or track is known as seek time. Once the head is at right track, it must wait

Recognition of essential syntactic constructs by reductions, Recognition of...

Recognition of essential syntactic constructs by reductions, this task is carried out by Recognition of essential syntactic constructs by reductions, this task is carried out

Cpu, Some CPUs provide for more than two modes of operation. What are two p...

Some CPUs provide for more than two modes of operation. What are two possible uses of these multiple modes?

Kernel mode and user mode function, Q. How does the distinction among kerne...

Q. How does the distinction among kernel mode and user mode function as a rudimentary form of protection (security) system? Answer: The distinction among kernel mode and user m

Developing code with threads, Developing Code with Threads Writing code...

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.

Medium term scheduler, Medium term scheduling is form of the swapping ope...

Medium term scheduling is form of the swapping operation. This attaches to processes that are in a suspended or blocked state. They are swapped out of real-memory storage until t

Explain deadlock, Explain Deadlock Every process in a set of processes ...

Explain Deadlock Every process in a set of processes is waiting for an event which only a process in the set can cause.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd