Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #225 > unrolled thread

reengineering c++ code that uses pthreads on Sun Solaris

Started byMy Python <mypython_2010@yahoo.com>
First post2011-06-01 18:22 -0700
Last post2011-06-03 10:56 -0500
Articles 9 — 9 participants

Back to article view | Back to comp.programming.threads


Contents

  reengineering c++ code that uses pthreads on Sun Solaris My Python <mypython_2010@yahoo.com> - 2011-06-01 18:22 -0700
    Re: reengineering c++ code that uses pthreads on Sun Solaris Joshua Maurice <joshuamaurice@gmail.com> - 2011-06-01 18:31 -0700
    Re: reengineering c++ code that uses pthreads on Sun Solaris Ian Collins <ian-news@hotmail.com> - 2011-06-02 13:41 +1200
    Re: reengineering c++ code that uses pthreads on Sun Solaris Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-02 06:06 +0000
    Re: reengineering c++ code that uses pthreads on Sun Solaris pasa <pasa@lib.hu> - 2011-06-02 03:01 -0700
    Re: reengineering c++ code that uses pthreads on Sun Solaris "Richard B. Gilbert" <rgilbert88@comcast.net> - 2011-06-02 10:36 -0400
      Re: reengineering c++ code that uses pthreads on Sun Solaris Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-02 20:42 -0400
        Re: reengineering c++ code that uses pthreads on Sun Solaris Miles Bader <miles@gnu.org> - 2011-06-03 10:39 +0900
    Re: reengineering c++ code that uses pthreads on Sun Solaris "Ira Baxter" <idbaxter@semdesigns.com> - 2011-06-03 10:56 -0500

#225 — reengineering c++ code that uses pthreads on Sun Solaris

FromMy Python <mypython_2010@yahoo.com>
Date2011-06-01 18:22 -0700
Subjectreengineering c++ code that uses pthreads on Sun Solaris
Message-ID<9dfaebc1-94b7-4e0d-b04b-30edfc99282c@d28g2000yqf.googlegroups.com>
greetings All,

Please respond to this posting if you have ever involved in a rewrite
of a complicated software system or driven such a project or have
insight into reengineering aspects:

Context:

Originally written using C++/pthreads on Sun Solaris, we need to
rewrite a component of a large system, so (A) the database,
communications (with other SW and devices), event management
infrastructure needs to be kept (so some reengineering in order), (B)
the rest of the logic code has to be rewritten or refactored whichever
suits the purpose.  (C) The primary purpose of the rewrite is the code
has become difficult to maintain. Over 180,000 lines of code and uses
pthreads, code was written about 10 years ago with lot of changes
impacting the code maintainablity to date.

Challenges:

1. Reengineering tool for reusing the classes by feeding this huge
amount of code (A). Rational rose chokes on this and I need a better
tool. Do any of you use a reeng tool for this size of C++ code, if so
throw some light this tool, forums, your experience using this, etc.

2. while the logic is complicated (B), there are several portions of
code which can be treated as modules and adapted to a clear threading
model, instead of what we have now a hodge-podge of thread startegies,
this will celar up the data sync issues (deadlocks) and race condition
related bugs. But I can't find any one book that addresses various
threading models with pthreads in context with examples (I need good
books pictures or diagrams). Any suggestions?

3. Any suggestions on code maintainability -- that is, the design
aspects we need to consider while rewriting. (C) Rather than pointing
to something like design patterns etc, what is really desired is
learning from how do others refactor/write (original code) large
amounts of code that interacts with lot of HW devices and SW
components?

Any URLs, case studies of such projects, responses to A,B,C 1,2,3 are
appreciated!

thanks!

[toc] | [next] | [standalone]


#226

FromJoshua Maurice <joshuamaurice@gmail.com>
Date2011-06-01 18:31 -0700
Message-ID<0e3c2b7c-2524-4a61-8b45-d94c62d24291@f31g2000pri.googlegroups.com>
In reply to#225
On Jun 1, 6:22 pm, My Python <mypython_2...@yahoo.com> wrote:
> 3. Any suggestions on code maintainability -- that is, the design
> aspects we need to consider while rewriting. (C) Rather than pointing
> to something like design patterns etc, what is really desired is
> learning from how do others refactor/write (original code) large
> amounts of code that interacts with lot of HW devices and SW
> components?

For my completely unknown and humble opinion, the key to avoiding this
kind of mess, and /perhaps/ what you should aim for, is well separated
components with clearly defined interfaces. Yes, I am saying not "full
agile". For large code bases, you do need some big design up front
insofaras it allows different teams to code to interfaces and not to
implementations. This doesn't mean strict waterfall, nor does it mean
that interfaces cannot change. I am trying to stress that the success
of a large code base depends on turning the large project into a bunch
of small ones. Break it up into logical distinct pieces that can be
tested separately and used together to build up more complex pieces of
software.

(End humble opinion.)

[toc] | [prev] | [next] | [standalone]


#227

FromIan Collins <ian-news@hotmail.com>
Date2011-06-02 13:41 +1200
Message-ID<94o81gF12lU16@mid.individual.net>
In reply to#225
On 06/ 2/11 01:22 PM, My Python wrote:
> greetings All,
>
> Please respond to this posting if you have ever involved in a rewrite
> of a complicated software system or driven such a project or have
> insight into reengineering aspects:
>
> Context:
>
> Originally written using C++/pthreads on Sun Solaris, we need to
> rewrite a component of a large system, so (A) the database,
> communications (with other SW and devices), event management
> infrastructure needs to be kept (so some reengineering in order), (B)
> the rest of the logic code has to be rewritten or refactored whichever
> suits the purpose.  (C) The primary purpose of the rewrite is the code
> has become difficult to maintain. Over 180,000 lines of code and uses
> pthreads, code was written about 10 years ago with lot of changes
> impacting the code maintainablity to date.

Read "Working Effectively with Legacy Code" by Michael Feathers

http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052

> Challenges:
>
> 1. Reengineering tool for reusing the classes by feeding this huge
> amount of code (A). Rational rose chokes on this and I need a better
> tool. Do any of you use a reeng tool for this size of C++ code, if so
> throw some light this tool, forums, your experience using this, etc.

No, they tend to be more trouble than they worth.

How does the SunStudio IDE cope with your code?  Once you ave the code 
assistance configured correctly, it is a great help navigating a new 
code base.

> 2. while the logic is complicated (B), there are several portions of
> code which can be treated as modules and adapted to a clear threading
> model, instead of what we have now a hodge-podge of thread startegies,
> this will celar up the data sync issues (deadlocks) and race condition
> related bugs. But I can't find any one book that addresses various
> threading models with pthreads in context with examples (I need good
> books pictures or diagrams). Any suggestions?

Have you considered an abstraction such as boot thread?

> 3. Any suggestions on code maintainability -- that is, the design
> aspects we need to consider while rewriting. (C) Rather than pointing
> to something like design patterns etc, what is really desired is
> learning from how do others refactor/write (original code) large
> amounts of code that interacts with lot of HW devices and SW
> components?

Write unit tests for the code you are about to change.  This will 
confirm your understanding of the behaviour of the code and validate 
your changes.

If they are not already separate, make sure your application logic is 
well isolated from your low level drivers.

-- 
Ian Collins

[toc] | [prev] | [next] | [standalone]


#232

FromJorgen Grahn <grahn+nntp@snipabacken.se>
Date2011-06-02 06:06 +0000
Message-ID<slrniuea3t.gtj.grahn+nntp@frailea.sa.invalid>
In reply to#225
["Followup-To:" header set to comp.lang.c++.]
On Thu, 2011-06-02, My Python wrote:
> greetings All,
>
> Please respond to this posting if you have ever involved in a rewrite
> of a complicated software system or driven such a project or have
> insight into reengineering aspects:
>
> Context:
>
> Originally written using C++/pthreads on Sun Solaris, we need to
> rewrite a component of a large system, so [...](A) the database,
> communications (with other SW and devices), event management
> infrastructure needs to be kept (so some reengineering in order), (B)
> the rest of the logic code has to be rewritten or refactored whichever
> suits the purpose.  (C) The primary purpose of the rewrite is the code
> has become difficult to maintain. Over 180,000 lines of code and uses
> pthreads, code was written about 10 years ago with lot of changes
> impacting the code maintainablity to date.

I am fairly convinced that the only right way to do such things is to:

- First spend time doing actual /maintenance/ work so you get to
  learn the code base in practice. IME, a messed-up code base has
  problems in many different areas, but some of them can be isolated
  and left as-is; they are not important[1].

- Improving it /incrementally/, and in the areas which matters.
  Don't spend months tinkering with the code in isolation.

- Having a good, close relationship with the users, so your
  incrementally improved versions actually get /used/.

- I should say something about a system test strategy here, too ...

- Since you use C++ already, use the features of C++ to tighten things
  up. Let classes to contain state. Use const. Use RAII. Use the
  standard containers. Let the type system find the bugs for you, and
  eliminate or isolate all type unsafety (casts, memcpy, malloc ...).

- Have a sane build system. where typing 'make' causes it to rebuild
  exactly those parts which need to be rebuilt, neither less nor more.
  I've worked with code bases where each build takes 30+ minutes.
  That means you can't do experimental/speculative changes, that you
  can't use the warnings from the compiler efficiently, ...

- I'm not a huge fan of unit tests, but I think you should make it
  easy to add unit tests (to the build system) in case they are
  needed. Sometimes you go "oh, this class would be so easy to write
  some tests for, and if I did I could stop worrying about it".

> Challenges:
>
> 1. Reengineering tool for reusing the classes by feeding this huge
> amount of code (A). Rational rose chokes on this and I need a better
> tool. Do any of you use a reeng tool for this size of C++ code, if so
> throw some light this tool, forums, your experience using this, etc.

Rational Rose is a "reengineering tool"?  I find it buggy and tedious
to use even as a mere drawing tool.  I also wouldn't be surprised if
IBM discontinues it soon in favor of some of its modern competitors
(which are, from what I've heard, also buggy and tedious).

I'd rather use Doxygen (with all graphs enabled) to try to squeeze
some kind of overview out of the code. And use pen and paper to make
temporary sketches of class diagrams and so on.  No generated diagram
can beat one which has been filtered by your brain.

> 2. while the logic is complicated (B), there are several portions of
> code which can be treated as modules and adapted to a clear threading
> model, instead of what we have now a hodge-podge of thread startegies,
> this will celar up the data sync issues (deadlocks) and race condition
> related bugs. But I can't find any one book that addresses various
> threading models with pthreads in context with examples (I need good
> books pictures or diagrams). Any suggestions?

Sorry, no. I find it very difficult to clean up badly written threaded
code. Part of the problem is that it's hard to do it incrementally.

If the code doesn't use RAII-style locking, /that/ is at least something
that's easy to fix.

> 3. Any suggestions on code maintainability -- that is, the design
> aspects we need to consider while rewriting. (C) Rather than pointing
> to something like design patterns etc, what is really desired is
> learning from how do others refactor/write (original code) large
> amounts of code that interacts with lot of HW devices and SW
> components?

I don't get the reference to "HW devices". If you use an OS, you
should see it as I/O, which you perform by interacting with software
components.

> Any URLs, case studies of such projects, responses to A,B,C 1,2,3 are
> appreciated!

/Jorgen

[1] I once spent ~4 years maintaining a messy code base. After that,
    some big areas were still fodder for thedailywtf.com -- but not
    the areas which mattered for maintainability, stability or
    performance!

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .  .
\X/     snipabacken.se>   O  o   .

[toc] | [prev] | [next] | [standalone]


#234

Frompasa <pasa@lib.hu>
Date2011-06-02 03:01 -0700
Message-ID<607c46e8-474c-4cd6-81a9-bb85252fc23f@c26g2000vbq.googlegroups.com>
In reply to#225
"My Python" <mypython_2010@yahoo.com>
> Please respond to this posting if you have ever involved in a rewrite
> of a complicated software system or driven such a project or have
> insight into reengineering aspects:
...
FWIW  ACCU (www.accu.org) is just launching a mentored project around
book
'Working Effectively with Legacy Code'
http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052

[toc] | [prev] | [next] | [standalone]


#238

From"Richard B. Gilbert" <rgilbert88@comcast.net>
Date2011-06-02 10:36 -0400
Message-ID<F_adnblYXLqEPXrQnZ2dnUVZ_jmdnZ2d@giganews.com>
In reply to#225
On 6/1/2011 9:22 PM, My Python wrote:
> greetings All,
>
> Please respond to this posting if you have ever involved in a rewrite
> of a complicated software system or driven such a project or have
> insight into reengineering aspects:
>
> Context:
>
> Originally written using C++/pthreads on Sun Solaris, we need to
> rewrite a component of a large system, so (A) the database,
> communications (with other SW and devices), event management
> infrastructure needs to be kept (so some reengineering in order), (B)
> the rest of the logic code has to be rewritten or refactored whichever
> suits the purpose.  (C) The primary purpose of the rewrite is the code
> has become difficult to maintain. Over 180,000 lines of code and uses
> pthreads, code was written about 10 years ago with lot of changes
> impacting the code maintainablity to date.
>
> Challenges:
>
> 1. Reengineering tool for reusing the classes by feeding this huge
> amount of code (A). Rational rose chokes on this and I need a better
> tool. Do any of you use a reeng tool for this size of C++ code, if so
> throw some light this tool, forums, your experience using this, etc.
>
> 2. while the logic is complicated (B), there are several portions of
> code which can be treated as modules and adapted to a clear threading
> model, instead of what we have now a hodge-podge of thread startegies,
> this will celar up the data sync issues (deadlocks) and race condition
> related bugs. But I can't find any one book that addresses various
> threading models with pthreads in context with examples (I need good
> books pictures or diagrams). Any suggestions?
>
> 3. Any suggestions on code maintainability -- that is, the design
> aspects we need to consider while rewriting. (C) Rather than pointing
> to something like design patterns etc, what is really desired is
> learning from how do others refactor/write (original code) large
> amounts of code that interacts with lot of HW devices and SW
> components?
>
> Any URLs, case studies of such projects, responses to A,B,C 1,2,3 are
> appreciated!
>
> thanks!

Have you considered a "nervous breakdown"?  Suicide?

In the last twenty-five years or so "software engineering" has become 
some sort of a "discipline".  I've mislaid my copy of "The Mythical Man 
Month" but I think  the author was "Fred Brooks". I can't swear to it. 
Find a copy and read it.  Then re-read it!

It *might* be worth while to to re-engineer what you have but I would 
give serious consideration to designing and implementing a solution from 
the bottom up!

Good luck.  I'm afraid that you will need it!


[toc] | [prev] | [next] | [standalone]


#241

FromEric Sosman <esosman@ieee-dot-org.invalid>
Date2011-06-02 20:42 -0400
Message-ID<is9an7$dc7$1@dont-email.me>
In reply to#238
On 6/2/2011 10:36 AM, Richard B. Gilbert wrote:
> On 6/1/2011 9:22 PM, My Python wrote:
>> greetings All,
>>
>> Please respond to this posting if you have ever involved in a rewrite
>> of a complicated software system or driven such a project or have
>> insight into reengineering aspects:
>>
>> Context:
>>
>> Originally written using C++/pthreads on Sun Solaris, we need to
>> rewrite a component of a large system, so (A) the database,
>> communications (with other SW and devices), event management
>> infrastructure needs to be kept (so some reengineering in order), (B)
>> the rest of the logic code has to be rewritten or refactored whichever
>> suits the purpose. (C) The primary purpose of the rewrite is the code
>> has become difficult to maintain. Over 180,000 lines of code and uses
>> pthreads, code was written about 10 years ago with lot of changes
>> impacting the code maintainablity to date.
>>
>> Challenges:
>>
>> 1. Reengineering tool for reusing the classes by feeding this huge
>> amount of code (A). Rational rose chokes on this and I need a better
>> tool. Do any of you use a reeng tool for this size of C++ code, if so
>> throw some light this tool, forums, your experience using this, etc.
>>
>> 2. while the logic is complicated (B), there are several portions of
>> code which can be treated as modules and adapted to a clear threading
>> model, instead of what we have now a hodge-podge of thread startegies,
>> this will celar up the data sync issues (deadlocks) and race condition
>> related bugs. But I can't find any one book that addresses various
>> threading models with pthreads in context with examples (I need good
>> books pictures or diagrams). Any suggestions?
>>
>> 3. Any suggestions on code maintainability -- that is, the design
>> aspects we need to consider while rewriting. (C) Rather than pointing
>> to something like design patterns etc, what is really desired is
>> learning from how do others refactor/write (original code) large
>> amounts of code that interacts with lot of HW devices and SW
>> components?
>>
>> Any URLs, case studies of such projects, responses to A,B,C 1,2,3 are
>> appreciated!
> [...]
> It *might* be worth while to to re-engineer what you have but I would
> give serious consideration to designing and implementing a solution from
> the bottom up!

     Seconded.  The code in question is only 0.18Mlines of fairly
recent vintage, and you should be able to figure out its purpose
even if its implementation is unfashionable.  (Put it this way: If
you can't figure out the purpose, how will you know whether your
rewrite is successful?)

     So: Analyze, deduce a fresh set of specs, implement the specs,
test for adherence thereto.

     -OR-

     Think again about your reasons for jettisoning the existing
code.  From what you say, it really can't be All That Bad.  It uses
a recognized, standardized, and still-current programming language,
not some off-the-wall idiosyncratic extended Lisp-Basic blend.  It
uses a multi-threading framework that's also standardized, still
current, and supportable, not some ad-hoc collection of home-brewed
spin-locks.  It's possible you might be better off spending N man-
years on a cleanup than spending 2N wrestling with tools that get
you nowhere and another 8N on a re-implementation.

     Or not.  But base your decision on sound engineering estimates
and a rigorous cost-benefit analysis, not on a feel for what's
trendy today.  I can almost guarantee that if you reimplement just
to be trendy, by the time you're done the trend will have passed.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

[toc] | [prev] | [next] | [standalone]


#242

FromMiles Bader <miles@gnu.org>
Date2011-06-03 10:39 +0900
Message-ID<8739jrk81w.fsf@catnip.gol.com>
In reply to#241
I'm a bit confused about what it has to do with pthreads anyway --
don't most other thread packages use roughly the same model anyway?

If the code base is hard to maintain, maybe somethings has to be done,
but it would seem at first glance that the choice of thread package
isn't a main issue...

-miles

-- 
Mad, adj. Affected with a high degree of intellectual independence; not
conforming to standards of thought, speech, and action derived by the
conformants [sic] from study of themselves; at odds with the majority; in
short, unusual. It is noteworthy that persons are pronounced mad by officials
destitute of evidence that they themselves are sane.

[toc] | [prev] | [next] | [standalone]


#243

From"Ira Baxter" <idbaxter@semdesigns.com>
Date2011-06-03 10:56 -0500
Message-ID<xsKdnbPD5eqlmXTQnZ2dnUVZ5hadnZ2d@giganews.com>
In reply to#225
"My Python" <mypython_2010@yahoo.com> wrote in message 
news:9dfaebc1-94b7-4e0d-b04b-30edfc99282c@d28g2000yqf.googlegroups.com...
> greetings All,
>
> Please respond to this posting if you have ever involved in a rewrite
> of a complicated software system or driven such a project or have
> insight into reengineering aspects:
>
> Context:
>
> Originally written using C++/pthreads on Sun Solaris, we need to
> rewrite a component of a large system, so (A) the database,
> communications (with other SW and devices), event management
> infrastructure needs to be kept (so some reengineering in order), (B)
> the rest of the logic code has to be rewritten or refactored whichever
> suits the purpose.  (C) The primary purpose of the rewrite is the code
> has become difficult to maintain. Over 180,000 lines of code and uses
> pthreads, code was written about 10 years ago with lot of changes
> impacting the code maintainablity to date.
>
> Challenges:
>
> 1. Reengineering tool for reusing the classes by feeding this huge
> amount of code (A). Rational rose chokes on this and I need a better
> tool. Do any of you use a reeng tool for this size of C++ code, if so
> throw some light this tool, forums, your experience using this, etc.
>
> 2. while the logic is complicated (B), there are several portions of
> code which can be treated as modules and adapted to a clear threading
> model, instead of what we have now a hodge-podge of thread startegies,
> this will celar up the data sync issues (deadlocks) and race condition
> related bugs. But I can't find any one book that addresses various
> threading models with pthreads in context with examples (I need good
> books pictures or diagrams). Any suggestions?
>
> 3. Any suggestions on code maintainability -- that is, the design
> aspects we need to consider while rewriting. (C) Rather than pointing
> to something like design patterns etc, what is really desired is
> learning from how do others refactor/write (original code) large
> amounts of code that interacts with lot of HW devices and SW
> components?
>
> Any URLs, case studies of such projects, responses to A,B,C 1,2,3 are
> appreciated!

Not a particularly big system, but might be amenable to automated 
restructuring.
These papers should be relevant:

Akers, R., Baxter, I., Mehlich, M. , Ellis, B. , Luecke, K., Case Study: 
Re-engineering C++ Component Models Via Automatic Program Transformation, 
Information & Software Technology 49(3):275-291 2007. Available from 
publisher.
Akers, R., Baxter, I., Mehlich, M., Ellis, B., Luecke, K., Re-engineering 
C++ Component Models Via Automatic Program Transformation, Twelfth Working 
Conference on Reverse Engineering, IEEE, 2005.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.programming.threads


csiph-web