View Single Post
  #27   Spotlight this post!  
Unread 06-06-2002, 15:15
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Quote:
now, i need to send each byte out to it's own text file
I'm hoping you mistyped this. If not, you may want to reconsider your design, because if you put each byte into it's own file you'll be creating 1000 files per second, and there's a good chance that your program won't be able to create the files fast enough (creating a new file on a disk is really slow compared to accessing memory or something similar..)
Quote:
i don't really understand how threads work together, so i'm a bit confused on how the variable can go from the Read function to the main thread
Threading is definitely an advanced concept that can be hard to grasp at first. Having two threads of the same program running at the same time is very similar to having to separate programs running at the same time with one key difference (there's more, but for now this is the one you're concerned with): They share the same memory space. So, if you create an array (or struct, or whatever) before you create your threads, and then you pass that array pointer to any threads which you create, you can access that same location in memory from different threads. So in this case, you could have 1 thread that was reading information off the serial port and storing it into a buffer, and have another thread reading information out of that same buffer and doing something with it.

Unfortunately, if you start using shared memory like this, you have to take into account the situation where 1 thread tries to write to the same location in memory that another thread it trying to read from at the same exact time. This is a big issue with multithreaded programs. I won't go into it in this message, but if you'd like to know more about this just ask and I'll try to think up a way to explain how it all works without writing a novel here...