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


Groups > comp.programming.threads > #598

Threads and statically allocated buffer

From ittium <ittium@gmail.com>
Newsgroups comp.programming.threads
Subject Threads and statically allocated buffer
Date 2011-09-22 11:47 +0530
Organization A noiseless patient Spider
Message-ID <j5ejum$sd4$1@dont-email.me> (permalink)

Show all headers | View raw


Group,
I have a situation where I am using following shared data structures


1. static buffer char B[100] where Multiple threads are copying string 
on using memcpy without any lock.

2. Shared STL string, where multiple threads are assigning values 
without locks.

There are large number of instances of #1 but few instances of #2.

The code was working fine on a quadcore machine. Recently we moved the 
system to a 16 core machine.

We saw crashes in #2 which we solve by putting mutex around the shared 
string access.

We have not seen any crash(till now in our testing) in #1, my doubt is 
whether copying of data on a statically allocated buffer by multiple 
threads results in incorrect  behavior (since variable may not have the 
value that you were expecting) or it may result in to crash also.

As pointed out earlier there are large number of instances of #2, 
protecting them is a significant effort. I can live with incorrect 
behavior but crashes obviously have to be avoided.

thanks
Ittium

Back to comp.programming.threads | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Threads and statically allocated buffer ittium <ittium@gmail.com> - 2011-09-22 11:47 +0530
  Re: Threads and statically allocated buffer David Schwartz <davids@webmaster.com> - 2011-09-22 14:34 -0700
    Re: Threads and statically allocated buffer ittium <ittium@gmail.com> - 2011-09-24 10:08 +0530
      Re: Threads and statically allocated buffer David Schwartz <davids@webmaster.com> - 2011-09-24 12:42 -0700
        Re: Threads and statically allocated buffer ittium <ittium@gmail.com> - 2011-09-25 11:45 +0530
          Re: Threads and statically allocated buffer David Schwartz <davids@webmaster.com> - 2011-09-25 04:15 -0700
  Re: Threads and statically allocated buffer Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-09-24 09:16 +0200

csiph-web