• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

132 Neutral

About sam_hughes

  • Rank
  1. The actual number of threads depends on what those threads doing.  Suppose you have some multithreaded event-loop based server that you want to scale up to tons of users.  Then maybe you'd have exactly one thread per core.  (If you've got hyperthreading, one thread per half-core.)  On the other hand, if total CPU time (or L1/L2 cache usage) is not a bottleneck, maybe you'd want one thread per network interface, so as in some fashion to minimize latency (if you pin them the right way, and the kernel lets you tell it to do the right thing, etc, you avoid the trouble of having threads on different cores competing for the same network interface).  A more practical example is if you want a thread pool to do blocking file I/O calls (perhaps because you don't want to block CPU workers, and because async file I/O is often broken on Linux).  There is a maximum number of I/O requests that a kernel or disk can service simultaneously, and it makes no sense for there to be significantly more threads in your pool than that number.  But it does often make sense to have significantly more threads than the number of CPU cores you have, for that purpose.
  2. c++11 iteration and warnings

      You don't create "temporal" types in functional languages.  What are you talking about?
  3. Question about Java

    [quote name='elmepo' timestamp='1319629328' post='4877142'] I'm doing the bachelor of I.T. Because their Computer science course, on memory, had no software major in it, I also asked the course coordinator, and he advised me that BIT would be best, as it had the major in Software dev, so I'm guessing that the CS course either has no software major, or that it's not designed towards actually entering the field after graduation. The School I'm hoping to enter is Charles Sturt University, Aus, Wagga Wagga. It's no actually my preferred university, Id Actually prefer to go to either a full on software/game university, as they'd hopefully be focused and geared more on game dev, or alternatively, the Bathurst Campus, As they have a 3 year course, after which I'd get a year minimum of paid work with Sony (It's some deal they have) However they unfortunately don't offer the course here in Wagga, or by Distance, and I can't afford to really live away from home.[/quote] Charles Sturt University has a delightfully well-organized website! The adviser is wrong or your memory of him/her is wrong. The CS course at Bathurst is [i]much much much[/i] better than the Software Design & Development major available in Wagga Wagga. You can do the CS program at Bathurst via distance learning too. As far as I can tell it's only the 4 year "Bachelor of Computer Science (Games Technology)" program that's listed as "on campus", which is simply a superset of the 3 year CS program. Take a look at [url="http://www.csu.edu.au/courses/undergraduate/computer_science/course-structure"]http://www.csu.edu.a...ourse-structure[/url] . It says right there that distance education is an option. Also you can see there are lots of important courses that aren't part of Wagga Wagga's IT program, like Computer Organization, Operating Systems, Discrete Math, Computer Graphics, Linear Algebra, etc etc etc. Look at that page I linked to. You can choose one of two specializations, and both of them are great. I'd definitely recommend going for the CS course at Bathurst over whatever's at Wagga Wagga, going by what's on their website. There is also something to be said for attending in person. One of the main benefits of going to a University is the like-minded people you meet. You won't get that by a distance education. If you do CS at Bathurst, is that worth three years' rent + food? If you do distance learning, would you end up missing on-campus job fairs, or connections with people who work at such-and-such company after graduating? $8.5k (on-campus cost) is much less than the variance in software developers get after graduating, so it seems easy to rationalize this expenditure. Especially when you're getting a degree in a field that is largely untouched by the recession and involves developing actual skills that people are willing to pay a lot of money for. So, to summarize: 1. If you want to study software development, game development, or whatnot, you should [i]definitely[/i] do the CS program at Bathurst, not the IT software major at Wagga Wagga, if your uni of choice is CSU. The stuff at Wagga Wagga is practically a not an education. 2. You can do it by distance learning or on campus, and I think you'd be much better off living on campus even if you had to take a loan.
  4. I have no idea what you mean by "recursive". We use Valgrind all the time for testing a database server we develop. We generally use memcheck with leak-check=full and sometimes run drd with certain options as well. Memcheck will check for memory leaks (it's kind of trivial to do so), but I believe leak-check will get you very useful output about what allocated a given block. Memcheck will catch double frees, wild pointers, use of uninitialized memory, etc etc etc, and the quality of the output is improved with leak-check. (Or so I presume it's improved. I haven't really done any runs without --leak-check=full so I don't really know.) Regarding other options: We don't have --show-reachable set, probably just because memory leaks are very rare, and we've never needed to debug a reachable memory leak very closely. If somebody snuck into our test scripts and added the option, I don't think we'd turn it off. I don't know about the other options, but the documentation seems to be generally pretty clear. One indirect benefit of running valgrind is that it makes the CPU performance of your program really slow. As a result, this tends to uncover race conditions. We don't really use valgrind for profiling, we use oprofile for serious profiling, but right now the only reason we care about CPU performance is to make the valgrind tests run faster, and I've used the valgrind profiling tool for that purpose (just because it was a command line argument away). Almost all of our tests are run under valgrind+debug mode or release mode without valgrind, with a few core tests run under other combinations of options.
  5. Question about Java

    [quote name='elmepo' timestamp='1319602436' post='4877045'] Hey, I'm Hopefully going to be going into University Next year, doing a Bachelor Of I.T. One of the Majors for the subject is Software Development, Which I plan on doing, However, As I am able to choose from the different majors what subjects I want to learn (E.G. I could Major in Software, but Could Still do say, a part from the sys admin course instead of a section from the software major) Now, the Software Major has two courses to do with Java, Programming with Java 1 & 2. Now, I'm curious as to if I should attend these courses, or switch them with another subject, Because I already know 3 Languages (C++, Visual Basic, and C#, although That might as well be C++) So, would Java be a recommended Subject, especially for someone who is looking to get into game development? [/quote] If you want to get into game development, I'm not sure why you're getting a Bachelor's in I.T., and not C.S., unless all they have is a Software Development track of an I.T. major, in which case I'd personally avoid the school altogether. Also, it's hard to give recommendations about courses unless you tell us what school (and therefore what courses) you're actually talking about. Generally speaking, another option is to skip Programming 1 and take Programming 2. Looking at your previous posts in June, I'd say at that time you could certainly benefit from Programming 2 (or at least the version of that class I once had) but it really depends how fast the courses go and what they cover. But by the time a year rolls around, this might not be the case. The benefit won't be in learning Java, since you won't learn more than what would take a day or two to pick up for an experienced programmer, it will be in getting better at programming, since you are (or were, and possibly will be) kind of green. Ultimately the proper recommendation also depends on the courses that are available after Programming 1 & 2.
  6. Parent threads can't start their child threads, and child threads can't wait on their parent threads, because the jobs form a DAG and not a tree.
  7. Does VC++ allow triple pointers?

    Except for the problem of too many layers of indirection.
  8. You can use condition variables (though I'm not sure if pthread condition variables let you wait on them _after_ they've been pulsed, in which case we'd like thme to return immediately, so you might have to make your own kind on top of pthread condition variables), but in such a use case you'd have each job have its own i_am_finished condition variable, and have each job wait on each of its prerequisites' condition variables before starting. Another option is to change the API a bit and to have a thread that's in charge of waiting for certain threads to finish and starting threads that may start.
  9. boost::lambda predicate

    You can't access data members from lambda parameters. Think about how that could possibly be implemented. (It can't be.) You can overload functions but not that.
  10. You can do this with C++11 varargs features, or just by defining a bunch of overloads of Log(...), if it's not a preprocessor macro. Make a function with a bunch of parameters having an empty default value. Generally speaking when a function gets called, there's nothing that tells it how many arguments it has. It either gets that from one of the early arguments, the way printf does, or it just knows how many it's supposed to get, the way most functions are, or the last argument is followed by a special value such as NULL, the way execl and execlp do on some POSIX systems.
  11. I usually end up writing [code]for (int i = 0, e = vec.size(); i < e; ++i) { ... }[/code] simply to prevent the compiler from giving signed/unsigned comparison warnings.
  12. [quote name='Modred' timestamp='1314441314' post='4854377'] Topic title is pretty much what I am about to do. For certain operations I need to temporary remove elements from a list and after those operations are done they have to be reinsterted, but [i]at their old position[/i]. [/quote] You don't really need to remove the elements. Avoid removing them.
  13. [quote name='latent' timestamp='1314334679' post='4853928'] I wonder though - isn't b_to_a_index an intrinsic property of b, since b is (apparently) by definition a subset of a?[/quote] No because b_to_a_index is apparently a different array than b. And in lots of circumstances it [i]must[/i] be, like if you wanted to create an alternate ordering of an existing array. [quote name='latent'] And out of interest, - since I've managed to avoid the finer points of stl in the last decade or so - what's the benefit of using stl to traverse that array/vector over this:? [code] for (size_t i = 0; i < b.size(); ++i) [/code] [/quote] There is no real benefit, unless you find that iterators give marginally better performance.
  14. [quote name='smasherprog' timestamp='1312343589' post='4843902'] I wrote a network library written in c++, Mutli threaded, supports encryption [/quote] No. It's insecure. Can you guess how long it took to spot a flaw? [code] ECB_Mode<AES>::Encryption Encryptor; [/code] Even if you fix that, there are others. e: I didn't mean that to be as put-downny as that came out, but, uh, I guess it's too late. Anyway, making secure connections requires more than just picking a block cipher and using whatever cipher mode you want.
  15. To goto or not to goto?

    [quote name='Telastyn' timestamp='1313849660' post='4851598'] I've said it before, and I'll say it again: There is absolutely no viable use case for goto in my working environment (C# 4). [/quote] If you have a for loop inside a for loop, you should avoid using break or continue and instead be perfectly explicit by using a goto.
  • Advertisement