System Library Extensions (Services SDK)

The following are extensions made to the standard FreeBSD libraries to support processor affinity, and provide a fast mechanism to retrieve timestamps from the system.

These extensions include:

The following two examples demonstrate the use of the three pthread function extensions dpcumented here.

The first example demonstrates the use of the libpthread extensions pthread_attr_setcpuaffinity_np and pthread_attr_getcpuaffinity:

 void
 pthread_example() {
 
  pthread_attr_t attr;
   pthread_t tid;
   int cpu_num = 5;
   
   pthread_attr_init(&attr);
 
   if (pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)) {
        return -1;
   }
 
   if (pthread_attr_setcpuaffinity_np(&attr, cpu_num)) {
        return -1;
   }
 
   if (pthread_create(&tid, &attr, (my_pthread_loop_t)my_pthread_loop,
                      pthread_args_p)) {
        return -1;
   }
 
   if (pthread_attr_getcpuaffinity_np(&attr, &cpu_num)) {
        return -1;
   } else {
        printf("pthread bound to cpu %d\n", cpu_num);
  }
 
  return 0;
 }

The second example demonstrates the use of the function lw_getsystimes to retrieve the system timestamp and boot times.

An application that needs to get a continuous timestamp can call:

 lw_getsystimes(&ts, NULL); 

If it wants to get the boot time as well then it would call:

 lw_getsystimes(&ts, &boottime); 

For Further Reading

System Library Extensions API Reference
2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:26:47 2010 for Juniper Networks Partner Solution Development Platform JUNOS SDK 10.2R1 by Doxygen 1.4.5