Correction de la génération de montants de transfert et amélioration de la gestion des temporisations aléatoires
This commit is contained in:
parent
0e1da17bee
commit
5756c775a2
@ -63,7 +63,7 @@ void perform_transaction(int fd, int account_count) {
|
||||
// Calculer un montant aléatoire à transférer (max 20% du solde source)
|
||||
int max_transfer = from_balance / 5;
|
||||
if (max_transfer > 0) {
|
||||
int transfer_amount = rand() % max_transfer;
|
||||
int transfer_amount = rand() % max_transfer + 1;
|
||||
|
||||
// Effectuer la transaction
|
||||
from_balance -= transfer_amount;
|
||||
@ -89,7 +89,7 @@ void process_transactions(int transactions, int account_count) {
|
||||
|
||||
for (int i = 0; i < transactions; i++) {
|
||||
perform_transaction(fd, account_count);
|
||||
//usleep(rand() % 100000); // Temporisation aléatoire
|
||||
usleep(rand() % 100000); // Temporisation aléatoire
|
||||
}
|
||||
|
||||
close(fd);
|
||||
@ -127,7 +127,8 @@ int main(int argc, char *argv[]) {
|
||||
int num_processes = atoi(argv[1]);
|
||||
int transactions_per_process = atoi(argv[2]);
|
||||
|
||||
srand(time(NULL));
|
||||
unsigned int seed = getpid() ^ time(NULL);
|
||||
int random_value = rand_r(&seed);
|
||||
|
||||
// Calcul du solde total initial
|
||||
int initial_balance = calculate_total_balance();
|
||||
|
Loading…
x
Reference in New Issue
Block a user