gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

thread safe usage of multiple phones


From: Peter Koch
Subject: thread safe usage of multiple phones
Date: Sat, 15 Apr 2017 12:45:34 +0200

Peter

Dear Gnokii experts,

I'm using libgnokii for a very long time to sent certain log messages via SMS
to our administrators. A multithreaded application receives log messages
from different sources and stores them into our database. Urgent messages
will also be sent via SMS to our administrators.

Unfortunately the single Nokia 6310 phone (connected via serial cable)
has become a perfomance bottleneck and we are planning to use 5 Nokia 6230i
(connected via USB) instead.

Right now the daemon has one thread that sends out SMS and I would
like to start 4 more threads that will do the SMS-sending in parallel.

I'm afraight not all libgnokii routines are thread-safe. gn_cfg_info and
gn_gsm_info are two global variables that prevent concurrent usage of
at least gn_lib_phoneprofile_load_from_file(). But that's not a problem
since initialization of the phones can be done non-concurrent.

But what about gn_sms_send()? The whole idea is to call this routine
concurrently with 5 phones.

Can I call gn_sms_send(data1, state1) and gn_sms_send(data2, state2)
in two threads?

Here's a short summary of what I'm planning to do:

In main thread:
----------------------------------------------------------------------
for(i=0; i<max; ++i){
  gn_lib_phoneprofile_load_from_file("gnokiirc", configname[i], &state[i]);
  gn_lib_phone_open(state[i]);
}
for(i=0; i<max; ++i){
  start_separate_thread(&state[i]);
}

In separate threads:
----------------------------------------------------------------------
for(;;){
  wait_for_sms();
  get_sms_from_queue(&data);
  gn_sms_send(data, &state);
}

Any ideas or suggestions?

Kind regards

Peter

reply via email to

[Prev in Thread] Current Thread [Next in Thread]