/ Forside / Teknologi / Udvikling / C/C++ / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
C/C++
#NavnPoint
BertelBra.. 2425
pmbruun 695
Master_of.. 501
jdjespers.. 500
kyllekylle 500
Bech_bb 500
scootergr.. 300
gibson 300
molokyle 287
10  strarup 270
help me,c program
Fra : Nuno


Dato : 18-10-02 03:05

Greetings to all.



I'm from Portugal, and I'm a student of electronic engineering
"www.fe.up.pt". I have a discipline of operative systems that it is not the
type of thing that I like very much. To compose the scene our teacher give
us a really painful work to do until the o end of this semester. So I'm very
confuse in as to make, or mainly, to catch in this work. So I decide to come
here, to see if anyone could help me anyway. I know that this work is very
extensive and perhaps complex, I'm begging you to read at this and if that
is possible, to help me, I will be perpetual grateful.

This work i have to do is a mainly a program in c, and start to explain the
functioning of the program:



Objectives of this work:

-The final objective of this work is the development of an application
client/server that simulates some of the functionalities of a machine
ATM-Automated Teller Machine. The simulation will be done through processes
running in only one computer, the communication between client and server
made through FIFOS.



Specification of the work:

-The application to develop will be constituted by a client program who
makes the interface with the user and a server program that processes order
proceeding from the client. The server keeps a database of accounts of the
users. The information contained in the database, on each account, is the
following one: the name of the user and the sum of the balance. Some
customers can exist running simultaneously.



The client program must have the following functionality:

.. To ask for to the name and password to the user and to verify if this are
correct. For a question of implementation easiness, password is local and
only for all the common users. An user (administrator) with special
privileges have to exist, that will be indicated to follow; this user must
have one password different of password of the common users

.. In case that password is correct, it will have to present a menu, with the
operations that the user can effect, or else it will have to present an
error message

.. The menu to present to the common users for the client program will have
to include the following operations: to raise money, to deposit money, to
consult the balance and to leave

.. The menu of the administrator will have to include the following
operations: to create new account of client, to list the existing accounts,
to make shutdown of the costumer, to make shutdown of the server and to
leave

.. To send to the server, through a FIFO with name known of all the
customers, a message with the necessary information to the execution of the
service asked for the user

.. To wait for the reply of the server, envoy through a dedicated FIFO to the
client, and to present it the user.



The server program must have the following functionality:

.. To run in background and to accept the order of service and the command of
shutdown, from the clients

.. To be permanently to listening, in the FIFO with known name, of the order
sent by the clients

.. To launch one thread adequate to answer to each order of the customers

.. The reply to the customer thread. will have to be given by this

.. To refuse order of service that arrives after the shutdown command of the
server, sent by the client administrator, waiting, however, that reply is
given to the orders that they will be to be taken care of, before it ends.



Some details of implementation:

.. The relative information to the accounts of the users must be kept in an
Array, in core storage, during the execution of the serving process, being
kept in a permanent way in file (file of accounts), when shutdown of the
server will be made. The server must read the information contained in the
file of accounts to the Array, before initiating the attendance of the
clients

.. The internal Array of accounts will have to be always commanded and its
research made for binary research (to use qsort() and bsearch() of the
standard library of the C). It will have to grow when it will be case

.. The file of accounts is a text file, contends in the 1st line the number
of entries, followed of the entries, an entry in each one of the following
lines. Each entry is constituted by the name of client and the balance,
separate for "|", as it is illustrated following:

Example of content of accounts file:

3

Peter Norton|7500

Anna kournikova|1600000

Bono Vox|123456



The FIFO of reception of the orders of the clients, "request", must be
created by the server

.. Being "nnnnn" the PID of a client, the FIFO through which is sent the
answers to this client must have the name "ansnnnnn.". These FIFOS will have
to be created and destroyed per item of the clients. So that the server
program knows which the FIFO for where it must send messages/answers to the
clients, each order that a client sends to the server will have to contain a
field with the PID of the client

.. It is necessary to establish a protocol and format of messages to change
between clients and server. All the order of the clients must have a reply
of the server (for example, reply "OK", in the case of the order of creation
of a new account of client and shutdown).

.. Synchronization mechanisms must be foreseen between threads of the server
in order to prevent errors in the operations of creation of accounts,
survey, deposit and consultation of the balances

.. Shutdown of the server must be made in a synchronized way, guaranteeing
that the order that is to be taken care of is concluded. For this, it is
suggested the use of a flag, that will be activated when the server receive
the order of shutdown. After the flag have been activated the server will
not have to accept new orders, but it will have to wait that all threads,
that they are to take care of asked for, finish, before him self terminates.





General project of the server program:

.. to read the content of the file of accounts to the internal Array

.. to create FIFO of reception of orders of the clients (request)

.. while not to receive the command of shutdown

.. to read message, of the FIFO

. if it received the command of shutdown, to
activate flag of shutdown and o finish this cycle

. to remove of the message the PID of the client

. to create thread to serve the order contained in
the message, being passed to it as argument the PID of
the client

. (the reply to the client it must be
sent by thread, through pipe
"ansnnnnn")

.. to destroy pipe request

.. to wait that all threads finish

.. to write the content of the Array of accounts to the file of accounts



General project of the client program:

.. to wait that pipe of order reception (request) either created by the
server; if it will not be created to the end of 3 minutes, to write
message and to finish the program

.. to create pipe of reception of the answers to the order (ansnnnnn)

.. to send message to the server, with indication of the PID

.. to execute "an infinite" cycle (1)

. to repeat the reading of password of user until he is correct

. to repeat

. to present the menu (different consonant the type
of user)

. to read the option of the user

. if the option was "shutdown of the client", to
finish the cycle (1)

. if the option was "to leave", to come back to the
beginning of the cycle (1)

. to send message to the server, in accordance with
the option of the user, through pipe
"request";

(if pipe will have been destroyed, to finish the
cycle (1))

. to wait the reply, sent for the server through
pipe "ansnnnnn"

. to present the reply, formatted, in the screen

. to destroy pipe "ansnnnnn".





- the possible situations will have to be dealt with all error, not to be
indicated in the previous projects.




 
 
Byrial Jensen (18-10-2002)
Kommentar
Fra : Byrial Jensen


Dato : 18-10-02 05:20

Nuno <n_pinto25@hotmail.com> skrev:

> This work i have to do is a mainly a program in c, and start to explain the
> functioning of the program:

What is your question? You hopefully do not expect us to do your
homework, but we might answer concrete questions when you have
made an effort yourself. Remember to present your code when you
make a question.

Lars Kongshøj (19-10-2002)
Kommentar
Fra : Lars Kongshøj


Dato : 19-10-02 12:35

Man undrer sig over hvad, der får folk til at poste den slags. Har
manden slet ikke realitetssans? Et hurtigt tjek på google viser
naturligvis også, at han har postet sit indlæg i adskillige grupper.

--
Lars Kongshøj

Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408924
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste