CS640 Project Hints and Tips


  1. Requirements
  2. POSIX threads are NOT preemptive by default. What this means is that the CPU will not "timeslice" between the threads; instead, a thread will run until it blocks for some reason (i.e., file i/o, socket i/o, sleep, semaphore, etc.) and then choose another thread to run. So if one of your thread goes into a long while loop, it will never give up the CPU and any other threads will not get a fair chance to run on the CPU till the while loop ends.

    This is a way to make a POSIX thread preemptive, by which we mean that a thread will be scheduled by the kernel like a normal process, and get its "fair share" of the CPU. Following is the code:
      p_thread_attr_t *attr;
    
      p_thread_attr_init (&attr);
      p_thread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM); //system-wide contention
    
      p_thread_create (&tid, start_func, arg);
    
    Use this code with any thread creation and things will work as expected.

  3. Here is an example of the network.config file
    	// Here is a sample network configuration file.  
    	// The syntax should be clear.
    	// Comments must begin with "//"
    	Node 1 (sol23, 5630) links 4 2  
    	Node 2 (nova5, 5033) links 1 3
    	Node 3 (sol13, 5768) links 4 2 
    	// Blank lines are OK 
    	Node 4 (sol23, 5001) links 1 3 
    	//Node 5 (nova16, 2344) links 4 6
    	//Node 6 (nova16, 10203) links 5 1
    
    You can assume the correctness (both syntax and content) of the configuration file in your code; you can also assume the node number will always start from 1 then 2,3,....N where N is the total number of nodes.

  4. Service numbers identify the upper layer applications. i.e. No two applications on one node can share the same service number. One application typically has one service number associated with it. Sometimes one application can have several service numbers.

  5. It is possible to create more than one connections between a pair of SAPs.

  6. The field of credit is used by the receiver to tell the sender that how much buffer is left in the receiver window so that the sender won't send more than the credit to overflow the receiver. Formal name for "credit" is "AdvertisedWindow". Further information can be found in section "Flow Control" on page 298 in you text book.

  7. Once connection has been set up between the two end points, both ends should be able to send and receive data. You can implement this in you MNP layer either by a two-way virtual circuit or by two VCs with reverse directions (of course or by any other "fancy" VCs that you think it would work).