|
I just got a little bummed Boost.Thread only recently got something for setting a thread priority, so I'd have to go update my libraries before I can even mess around with it. Meanwhile I thought I'd ask if it was going to be worthwhile for what I want to do. I want to have some background work running to update some calculations with whatever spare cycles I have. However, when new data arrives I want to make sure processing reacts and responds to it fairly quickly. Like, within a second, the thread in charge of responding has gotten itself a core and is actively using it the majority of time. I was originally going to throw together something synchronizing between a background service and this foreground work, when I realized this is probably a job for thread priorities. Generally I'd give the sensitive thread the high priority, and give the background the lower priority. I should be fine if the lower priority stuff still runs a little bit as the higher priority one works. Something I wonder is how much control I really get. Chances are I'll have to doodle something up just to see for certain, since I haven't actually ever messed with thread priorities before. It's just when I have to update my environment to Boost 1.52 that it gets to be a tough to just throw down an experiment. This is on Windows, but possibly Linux someday, if that helps.
|
# ? Nov 20, 2012 06:31 |
|
|
# ? Jun 1, 2024 12:28 |
|
Another question worth considering is, is using the native threading libraries and recognizing Windows with a conditional compilation actually that painful? I'd be willing to use Boost threads as a general concurrency mechanism, but when you're at the point where you're telling the operating system about thread priorities, it sounds like going native might be easier in the long run.
|
# ? Nov 21, 2012 05:49 |
|
Ehh maybe. I actually swallowed the pill and built Boost 1.52. I have some notions that building Boost had been a pain in the rear end in the past. I think it screwed up finding some paths from Visual Studio in prior versions. This time, it built fine without a problem. Granted, I didn't try to build Boost.Python like I have tried to do previously. I haven't had any time to try any experiments with thread priorities yet though.
|
# ? Nov 22, 2012 07:19 |
|
Rocko Bonaparte posted:Ehh maybe. I actually swallowed the pill and built Boost 1.52. I have some notions that building Boost had been a pain in the rear end in the past. I think it screwed up finding some paths from Visual Studio in prior versions. Anyway, use Boost or the new standard threading library unless you have some very specific reason not to. Even if you want to do something that's not directly supported, you can often do so without resorting to always manually dealing with Windows threading for everything. It's generally not an all-or-nothing decision. In other words, using the standard threading library or Boost with a branch or two in the places where you absolutely need to deal with the OS is better than simply doing everything in a non-portable manner.
|
# ? Nov 22, 2012 08:48 |
|
Is that true for Boost.Python? Last I tried (earlier this year) it was a shitfight and the mailing lists were peppered with "it doesn't work" "works for me!" and no actual real information. I think I ended up building with MinGW instead of VC++ and even then only one of the examples worked, so I gave up and switched to LUA for what I wanted.
|
# ? Nov 22, 2012 09:26 |
|
The Gripper posted:Is that true for Boost.Python? Last I tried (earlier this year) it was a shitfight and the mailing lists were peppered with "it doesn't work" "works for me!" and no actual real information. Yes. Also, there is a guide specifically for Boost.Python.
|
# ? Nov 22, 2012 09:35 |
|
That's the guide I followed, and it failed spectacularly over the course of almost 2 days. I'll give it another try on this system (different VC) and see if it's any better, but honestly the last experience soured me on it enough that I'm not going to expect anything better than total failure! Edit; Well, it looks like it actually does build properly now. Last time I was lost in an endless sea of unresolved externals. I can't test the embedding feature (tests fail, but that's because Python is built with MSVC++ 2008 and I only have 2010+), but it's good to know it's not thrown into the "doesn't work, don't care" pile. The Gripper fucked around with this message at 10:15 on Nov 22, 2012 |
# ? Nov 22, 2012 09:46 |
|
The Gripper posted:Last time I was lost in an endless sea of unresolved externals. That's really... odd. Were you building static link libraries or dynamic link libraries? The Gripper posted:I can't test the embedding feature (tests fail, but that's because Python is built with MSVC++ 2008 and I only have 2010+), but it's good to know it's not thrown into the "doesn't work, don't care" pile.
|
# ? Nov 22, 2012 17:59 |
|
I guess this is the place to ask this. I've been given coursework for a C++ class I'm taking but the API he's given us only compiles on older versions of g++, particularly 4.1.2, what we have running in the Linux labs here. I've got g++ running on my Windows 7 home pc through a few different methods, but only the newer versions, and I have no idea how to get it installed. Can someone give me a comprehensive guide to installing g++ 4.1.2?
|
# ? Nov 23, 2012 01:16 |
|
Fix the API.
|
# ? Nov 23, 2012 17:00 |
|
Vanadium posted:Fix the API. Well, that's one way to learn ;-) Sometimes -fpermissive helps a bit, though it's usually for stuff that's way older than 4.1.2.
|
# ? Nov 23, 2012 17:55 |
|
I'm getting a different error now, so either it's fixed and moved on to something else, or this one is happening before it can even get to the next bit.code:
|
# ? Nov 23, 2012 18:43 |
Praseodymi posted:I'm getting a different error now, so either it's fixed and moved on to something else, or this one is happening before it can even get to the next bit. You're building the program as a Windows subsystem (as opposed to Console subsystem) program, and you don't have the WinMain() entry point function required for that. There is some flag you need to give, either during compilation or during linking (not sure) to tell that you want a Console subsystem program, i.e. a standard POSIX-style main() entry point.
|
|
# ? Nov 23, 2012 18:50 |
|
Add -mconsole to your linker flags. Although I believe that is the MinGW default value anyway, so remove any -mwindows or -Wl,-subsystem,windows flags you may use.
|
# ? Nov 23, 2012 18:58 |
|
That Turkey Story posted:That's really... odd. Were you building static link libraries or dynamic link libraries? On the threading front, I see 1.52 technically doesn't provide a cross-platform way to set a thread priority, but it at least provides a native handle where I could make the appropriate call on whatever platform I'm on. I wrote a little experiment with it overnight, and indeed saw a lower priority thread get less work done in a unit time than a normal priority thread. Edit: I can't really blame Boost on this because the impression I get of Python culture is it's fine for Python to import native code or other runtime stuff, but it is notoriously a pain in the pass to get it to embed the other way. The global interpreter lock is at the top of my poo poo list there. I hate that drat thing.
|
# ? Nov 23, 2012 19:22 |
|
Is there a thing that acts a C preprocessor but instead of spitting out preprocessed source it prints all the defined macros? If not, how else do people autogenerate language bindings that include symbolic constants?
|
# ? Nov 24, 2012 02:08 |
Vanadium posted:Is there a thing that acts a C preprocessor but instead of spitting out preprocessed source it prints all the defined macros? If not, how else do people autogenerate language bindings that include symbolic constants? Something like that? vvv right scratch that
|
|
# ? Nov 24, 2012 02:11 |
|
But cpp processes definitions and does the whole substitution thing, it doesn't output the definitions again.
|
# ? Nov 24, 2012 02:12 |
|
-dM with gcc.
|
# ? Nov 24, 2012 02:24 |
|
Vanadium posted:But cpp processes definitions and does the whole substitution thing, it doesn't output the definitions again. gcc has -E -dM which prints defined macros out, see: http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Preprocessor-Options.html#index-dM-972 (Though I don't see the connection with bindings)
|
# ? Nov 24, 2012 02:25 |
|
OddObserver posted:(Though I don't see the connection with bindings) Code that generates bindings want to grab #define constants so that those are bound as well.
|
# ? Nov 24, 2012 02:44 |
|
Cheers, I somehow missed that in man gcc, I even only read the preprocessor-specific options. OddObserver posted:(Though I don't see the connection with bindings) I wanted to call some termios stuff and it looks like the API is 95% #defined constants. There's a thing that gives me a definition for the termios struct and the dozen functions it comes with, but that doesn't get me very close to fiddling with the right bits. Vanadium fucked around with this message at 02:50 on Nov 24, 2012 |
# ? Nov 24, 2012 02:47 |
|
If I'm doing division FP math with constants, will MSVC optimize them into multiplications, or will I have to deal with this by hand? Say something like this: #define RT_FREQUENCY 44100.0 #define RT_FREQUENCY_RECIP (1.0 / RT_FREQUENCY) ... double stuff = somevalue * RT_FREQUENCY_RECIP;
|
# ? Nov 24, 2012 23:57 |
|
Short answer: Most of the time, yep. Long answer: The two operations aren't strictly equivalent for all values and the compiler takes this into account. As a result /fp:strict and /fp:precise will do that transform if and only if the compiler can guarantee that the result is equivalent. /fp:fast will do algebraic transforms willy-nilly if it thinks it'll gain from them. Here's more detail on the subject. Article is a bit old but I'm pretty sure that part hasn't changed any.
|
# ? Nov 25, 2012 00:11 |
|
Cool, thanks. I'm using fp:fast anyway. The application is a simulation of an analog synthesizer, so precision errors aren't an issue, actually even desired.
|
# ? Nov 25, 2012 00:13 |
|
This is pretty basic so has probably been answered several times in this thread but if it hasn't here goes... When you have an array of something how do you change the size of the array dynamically without deleting any of the data in it? can I just do something like code:
For some context I am trying to create slices in an audio file. The user clicks to create a point and shift clicks to delete one. They are basically just structures with a couple variables one of which is dependant on data from the previous location in the array. Cheers! Edit: Just incase I get the obvious let me google that for you response, the only stuff I have found shows you how to make an array you don't know the size of pre-compile time. What I am trying to do is make an array who's size can change at any point in the running of the program. It's possible I haven't been googling using the right terminology as I am quite new to all this. jiggerypokery fucked around with this message at 15:42 on Nov 25, 2012 |
# ? Nov 25, 2012 15:37 |
Don't use raw arrays. Use the container types provided by the standard library, such as std::vector. (The std::vector type will maintain an array for you under the hood. When it needs to grow to fit more items, it allocates a new array of the required size and copies all the objects to the new array, then deletes the old array. Don't do that yourself, implementing it on your own is error-prone and a waste of time when there is already a perfectly good implementation available.)
|
|
# ? Nov 25, 2012 15:41 |
|
I see. I had the feeling that you would need to do something like this because of pointers just moving through locations in memory. I figured they cant just jump so I must be missing something. Nice one! Edit again: This time google proves fruitful when It comes to making vectors of structures! jiggerypokery fucked around with this message at 16:07 on Nov 25, 2012 |
# ? Nov 25, 2012 15:45 |
|
I would just like to write out my understanding of a situation before I make any purchases, and see if people who know what the hell they're doing can find any fault in it. I am watching lectures for Standford 106B Open Courseware as a way to learn C++ syntax and become a better programmer. The lectures have been really good and informative. The problem is the homework. The OCW comes with a library that is a binary blob built with VC2005, along with header files. I have tried many things to make this work so that I can do the homework assignments. 1. Download VC 2010 Express, create a blank project, add the header file, add the .lib file to resources, add the lib/include paths to the linker/compiler settings, and compile. -->Linker errors abound. Am I to conclude that I can't link a static library built with a different version of Visual Studio? 2. Download VC 2005 Express, create a blank project, add the header file, add the .lib file to resources, add the lib/include paths to the linker/compiler settings, and compile. -->Linker errors. Specifically: code:
I honestly have no idea what is wrong with this. It's the same version of the compiler. 3. Google. There exists an open source version of the library that some random learner put together, but it doesn't compile on Windows. So a couple of general questions. 1. Is it possible to use a binary blob made with a different version of Visual Studio? 2. If I add the path to the library as a library search directory, why would I even have to add it to the project? (I get even more linker errors when I don't add it to the project). Wouldn't it be possible to either add it to the project or have it living in a pointed-to lib directory? 3. As far as I can determine, here is the process for using an external library: point the user-defined include and lib directories to it, add the lib file to your project. Is there some kind of integral step I'm missing? 3. What would you do? Develop for the class in a virtual machine using the hacked-together ones? Install Visual Studio 2005 professional? Find another course? I really like the lecture / homework format of the class--it's familiar and keeps me motivated to have a consistent, well thought-out curriculum--but I've spent more time staring at Windows installer than I have coding. edit: Worth noting that I am aware that newer versions of the library exist, but the homework assignments for the original class don't compile using them. They have changed the interface a little bit. I managed to do the first homework assignment just porting the skeleton code over, but doing that for every homework assignment seems infeasible. The Gay Bean fucked around with this message at 08:49 on Nov 26, 2012 |
# ? Nov 26, 2012 08:46 |
|
Praseodymi posted:I'm getting a different error now, so either it's fixed and moved on to something else, or this one is happening before it can even get to the next bit. Me again. After giving up briefly and just doing it in the labs I've returned now sure that it's not my fault and that everything should be working, but I'm still getting this error despite my best efforts, and I think that once again this is a problem with the API. I'm passing -mconsole to the linker using -Xlinker, is this correct? My shiny new error is: code:
Praseodymi fucked around with this message at 17:43 on Nov 26, 2012 |
# ? Nov 26, 2012 17:40 |
You should probably post the entire command line that is being executed.
|
|
# ? Nov 26, 2012 17:54 |
|
Never mind, I got it working. While loving around with the command line I'd got rid of something I shouldn't have !
|
# ? Nov 26, 2012 18:04 |
|
I saw http://llvm.org/devmtg/2012-11/Gregor-Modules.pdf, the slides of a presentation by some clang dude about their proposed C module system, but I haven't been able to find much more info on that. Sounds like Gregor is chairing the C++ committee subgroup on modules, and judging from the test/modules/ directory in the clang tree, they seem to be fairly far along already. So is there some user-facing documentation that I've missed or maybe some more detailed writeup about their proposal? I'd love to play around with some new C++ toys but I haven't been able to prod my clang binary into actually compiling anything
|
# ? Nov 26, 2012 18:38 |
|
I need to make a hash table in c++ to use for a simple two letter word dictionary for school. Does anyone have an idea for a decent/simple hashing function I could use?
|
# ? Nov 27, 2012 00:01 |
an skeleton posted:I need to make a hash table in c++ to use for a simple two letter word dictionary for school. Does anyone have an idea for a decent/simple hashing function I could use? First character of word. (Serious.)
|
|
# ? Nov 27, 2012 00:06 |
|
char1 ^ char2 char1 + char2 etc
|
# ? Nov 27, 2012 00:11 |
|
*((uint16_t *)(word))
|
# ? Nov 27, 2012 01:21 |
|
srand(*((uint16_t)(word))), rand();
|
# ? Nov 27, 2012 02:51 |
|
what is uint_16t? Unsigned Int... 16 T? Also, what does unsigned mean? apologies if these are horrible questions/I deserve to die for asking them.
|
# ? Nov 27, 2012 03:02 |
|
|
# ? Jun 1, 2024 12:28 |
|
an skeleton posted:what is uint_16t? Unsigned Int... 16 T? Also, what does unsigned mean? uint16_t is platform / compiler independent unsigned 16 bit integer type. See stdint.h xgalaxy fucked around with this message at 03:08 on Nov 27, 2012 |
# ? Nov 27, 2012 03:05 |