Add Book to My BookshelfPurchase This Book Online

Appendix A - Pthreads and DCE

Pthreads Programming
Bradford Nichols, Dick Buttlar and Jacqueline Proulx Farrell
 Copyright 1996 O'Reilly & Associates, Inc.

Appendix A: Pthreads and DCE
The Distributed Computing Environment (DCE), developed by the Open Software Foundation (OSF), consists of a toolkit and library that simplify the creation of secure, portable, and distributed applications for heterogeneous environments. Although DCE contains a great number of programming tools and server programs (and even supplies its own file system), we'll focus on its programming library and run-time environment in this appendix. 
DCE-based applications consist of client programs and server programs that use remote procedure calls (RPCs) to communicate with each other. Their client-server structure makes DCE applications natural candidates for threading. In fact, thread support is tightly integrated into the DCE libraries and services. We'll use this appendix to give you an idea of the role threads can play in a DCE-based application. 
DCE currently provides and uses the Draft 4 Pthreads interface. Check out Appendix B for a summary of the differences between the final Pthreads standard (which this book describes) and Draft 4. 
The Structure of a DCE Server
A DCE server performs the same type of work as other servers. It waits for client requests on a communication channel and processes requests as they arrive. In fact, a DCE server looks just like any of the boss-worker style servers that we've presented elsewhere in this book, but it can take advantage of DCE library routines that: 
 Automate the task of generating the more mundane server components. 
 Transparently perform any data conversions that are required when servers or clients running on different platforms intercommunicate. 
 Integrate RPC services with other important DCE services, such as the security service and the name service (which locates resources for your program on remote systems). 
To allow a DCE server to process multiple requests concurrently, its engine uses POSIX threads. 
Let's look back at the ATM server program we've been using as an example. Figure A-1. illustrates the components of our original version of the server; Figure A-2 shows how the server would look in a DCE implementation. 
Figure A-1: Original ATM server components
We can map each component in the original ATM server to a similar component in the DCE version of the server, as shown in Table A-1. We'll compare each component of the original server with its corresponding component in the DCE version in the following sections of this appendix. 
Figure A-2: The ATM as a DCE server
Table A-1: ATM Server Components: Original Version vs. DCE Version
Original Server Component
DCE Server Component
Communicating with clients
Home-grown communication module that uses BSD sockets
DCE run-time library's transport layer interface
Waiting for clients
Boss thread's request-processing loop in main routine
Boss thread calls rpc_server_listen DCE library routine
Performing tasks
Worker thread routines
Server management routines
Unmarshaling and marshaling client/server messages
Boss thread's request-processing loop in main routine and worker threads' start routine.
Stub routines

Previous SectionNext Section, Inc 2000   Feedback