i have to make a information system using threads than [url removed, login to view] on the model client / server that has already been implemented, should make all semaphores necessary changes to use tree in place of the previous tools (fork, exit, shared memory,). The implementation will be carried out using tree should support exactly the same functions as the implementation using the [url removed, login to view] i can give and the first exercise
The executives of GiveMeYourMoney Bank is very happy with your efforts so far to develop the information system of the bank. Certainly, the experience gained so far in helping you spot some problems in the current implementation of the system. First, he realized that the management of shared memory between processes is too complicated and too restrictive, since the size can not be arbitrarily large. In short, the management of accounts will face major problems when trying to add the accounts of all customers of the bank. Furthermore, using fork to create a new process to suit each new application is particularly time consuming, but it also requires a large number of resources. The result is that the maximum number of applications that can be served simultaneously is significantly reduced Having developed the above problems in the bank's executives, I was to recommend and implement solutions to these issues. The solution chosen is used to threads than the fork. After all, the use of tree first solve the problem of wasting system resources, since threads share many of the resources of the process to which they belong, and also solve the problem of shared memory, as one of the resources they are sharing space memory address of the process. Based on the model client / server that has already been implemented, should make all semaphores necessary changes to use tree in place of the previous tools (fork, exit, shared memory,). The whole exercise should still be implemented and assimilated in the central server available to the bank. The implementation will be carried out using tree should support exactly the same functions as the implementation using the fork. Comments: The aim of the exercise is to familiarize the tree using the standard POSIX (POSIX Threads or PThreads). The functions you will need include: 1) pthread_create () and pthread_exit () to create and manage tree (probably the pthread_detach (), depending on how you use pthread_create ()) 2) pthread_mutex_init (), pthread_mutex_lock (), pthread_mutex_unlock () and pthread_mutex_destroy () to synchronize threads. The server is a process that runs in the background (background). The server will bind a segment, which will save all information for each account. For each application receives the server creates a new thread, which will serve the request. The server will immediately goes back into standby mode, waiting for the next request. Implementation does not need to explicitly create shared memory because the threads by definition share the address space of the process. The threads servicing requests should be closed properly so the system can not remain useless threads. The client is a process that runs in the foreground (foreground) and communicates with the server via sockets. Once the cashier completes the necessary information will be sent to the server and updated the account to the client. Caution is required because it can be run concurrently many clients. Therefore, the updated information from the threads that will create the server should be protected by some method of synchronization. Because the variables used for synchronization should be accessible to all threads created by the server, these variables should be shared. Control accuracy: To make sure that the server functions are implemented correctly (especially timing), you can create clients who would not expect input from the user, but sending predetermined information to an account on the server. For example, the client can make statements 1000 and 1000 commitments turn the same amount in a single account. With a script you can start with 10 clients. If you run the experiment many times and end of each performance the amount left in the account is the same as the original amount, then probably your program is correct. The code of the client that will deliver but we must accept the data from each user. Procedural: 1) The code will deliver should be well structured. 2) The code will deliver should be well annotated 3) The code should use the tools mentioned earlier (pthread_create, pthread_exit, pthread_detach, pthread_mutex_init, pthread_mutex_lock, pthread_mutex_unlock, pthread_mutex_destroy).