asst1-Synchronization/kern/asst1/client_server_tester.c
static void
server_thread(void *unused_ptr, unsigned long server_id)
{
        request_t  *req;
        int delay;

        (void)unused_ptr;

        kprintf("Server %ld started\n", server_id);

        req = work_queue_get_next();

        while (req != NULL) {
                
                /* insert a random delay representing some kind of
                   processing or I/O */

                delay = random() % 16;
                for (int i = 0; i <= delay; i++) {
                        thread_yield();
                }

                /* process the request, which in this case is just
                   writing a check word that is a function of the
                   number in the request */
                req->check = ~(req->number); 

                processed[server_id]++;

                V(req->done); /* signal the request is done to the
                                 client */

                req = work_queue_get_next();
        }

        /* We got a NULL, so signal that we're done. */
        V(servers_finished);
}
/***********************************************************************
 * The server thread's function. NUM_SERVER threads are started, each
 * of which runs this function. The function continuously calls
 * work_queue_get_next() until it receives a special NULL request.
 */
The server thread's function. NUM_SERVER threads are started, each
of which runs this function. The function continuously calls
work_queue_get_next() until it receives a special NULL request.
The server thread ' s function . NUM_SERVER threads are started each of which runs this function . The function continuously calls work_queue_get_next () until it receives a special NULL request .
static void
server_thread(void *unused_ptr, unsigned long server_id)
{
        request_t  *req;
        int delay;
        (void)unused_ptr;
        kprintf("Server %ld started\n", server_id);
        req = work_queue_get_next();
        while (req != NULL) {
                delay = random() % 16;
                for (int i = 0; i <= delay; i++) {
                        thread_yield();
                }
                req->check = ~(req->number); 
                processed[server_id]++;
                V(req->done); 
                req = work_queue_get_next();
        }
        V(servers_finished);
}
static void server_thread ( void * unused_ptr , unsigned long server_id ) { request_t * req ; int delay ; ( void ) unused_ptr ; kprintf ( " \n " , server_id ) ; req = work_queue_get_next ( ) ; while ( req != NULL ) { delay = random ( ) % 16 ; for ( int i = 0 ; i <= delay ; i ++ ) { thread_yield ( ) ; } req -> check = ~ ( req -> number ) ; processed [ server_id ] ++ ; V ( req -> done ) ; req = work_queue_get_next ( ) ; } V ( servers_finished ) ; }
The server thread's function.
The server thread ' s function .
/* insert a random delay representing some kind of
                   processing or I/O */ /* process the request, which in this case is just
                   writing a check word that is a function of the
                   number in the request */ /* signal the request is done to the
                                 client */ /* We got a NULL, so signal that we're done. */