My favorite beginner level breakdown of this background info is Security Now #254 - What We'll Do For Speed, FWIW.http://www.lighterra.com/papers/modernmicroprocessors/
A fantastic article about modern CPU architecture. It requires a basic understanding of CPU architecture, pipelining, caches and so on. (as you would get in an introductory computer architecture course)
I've got a mid-term exam next Monday (Intro to Programming - c#), and I'm struggling a bit with Loop and if/else structures.
Some of the problems I'm struggling with.
Yes they do. Thanks for the answer. When a process is terminated that will also context switch correct?Do "write" and "read" mean "open for write, write" and "open for read, read"?
If so, all of the calls will block (and thus require a context switch to be unblocked)
.
I've got a mid-term exam next Monday (Intro to Programming - c#), and I'm struggling a bit with Loop and if/else structures.
if (test) {
//executes if test is true
} else {
//executes if test is false
}
//adds the numbers 3-10
i = 3
sum = 0
limit = 10
while (i <= limit) {
sum = sum + i
i++
}
Do sideprojects you want to do, like make small games?
You could take a look at LibGDX and use that to make something. I'm in a similar situation (will start university in October) and that's what I'm doing.Well, I'm only in my second semester so my knowledge is vast by any means. Can you recommend me a good place to start possibly? Either a solid website resource or book?
That sounds like the kind of stuff I would love to do in my free time.
Question: What did you guys do at an entry level to improve your programming?
I'm in my second semester of College learning Java (I have some experience with Python as well, mainly syntax), but I don't feel as though the programming we do is very challenging or productive. Half the time we are learning 'theory' and won't do any assigned programming for 2-3 weeks at a time. To make up for it I would spend time on Codingbat or CodeAcademy, but those almost seem monotonous and uninteresting to me. I like solving problems, but can't think of a good way to get experience coding on a basic level in my free time.
suggestions?
Question: What did you guys do at an entry level to improve your programming?
I'm in my second semester of College learning Java (I have some experience with Python as well, mainly syntax), but I don't feel as though the programming we do is very challenging or productive. Half the time we are learning 'theory' and won't do any assigned programming for 2-3 weeks at a time. To make up for it I would spend time on Codingbat or CodeAcademy, but those almost seem monotonous and uninteresting to me. I like solving problems, but can't think of a good way to get experience coding on a basic level in my free time.
suggestions?
Write some gamesQuestion: What did you guys do at an entry level to improve your programming?
I'm in my second semester of College learning Java (I have some experience with Python as well, mainly syntax), but I don't feel as though the programming we do is very challenging or productive. Half the time we are learning 'theory' and won't do any assigned programming for 2-3 weeks at a time. To make up for it I would spend time on Codingbat or CodeAcademy, but those almost seem monotonous and uninteresting to me. I like solving problems, but can't think of a good way to get experience coding on a basic level in my free time.
suggestions?
Placement new is weird, amazing, and the use of it to re-initialize pool objects should be supported with the renew keyword in C++. Or something.
The best part of C++ is that there's a new operator and operator new. They are not the same thing.Update:
Don't listen to this idiot. Placement new is evil. :V
Question: What did you guys do at an entry level to improve your programming?
we explicitely declare all of our destructors and make them virtual.
Since they were all trivial, we believed it was safe to not call the object destructors before using placement new.
Well... problem is, they had standard library strings as data members, which are not non-trivial. So even though our objects have trivial destructors, we have to call them
The fun part is I checked for memory leaks by triggering the placement new a few thousand times in a test rim while monitoring the heap size.
Saw no problems, none of the code inspectors saw an issue either, so we thought we were good to go.
well... we have a 500 MB heap, and we're leaking only between 4 and 32 bytes of memory each time we do this, so there's no way a single tester could have caught this.
Hooray for hidden surprises
More programming.
This is obviously my intention, but the pace at which our curriculum is moving (5 weeks into my seconds semester and we are just now moving into working with multiple connected classes...) isn't doing it for me.
If you're dissatisfied with your university, and don't feel you're getting good schooling for your money then switch.
When people say your undergraduate university isn't important, they mean that most schools offer programs of similar quality and most employers are not going to judge you based on the school name.
They don't mean that the schooling is unimportant. A good education is definitely important, and if you are not getting it from your university, then absolutely, you should switch universities.
Depends what you mean. Strictly speaking (from the perspective of the cpu) yes, since it's going to unload the context and do something else, but the process doesn't care anymore since it's dead jim!Yes they do. Thanks for the answer. When a process is terminated that will also context switch correct?
It sounds like what you want to do is capture the images, process them in program A, then send them over to program B, which does something else with them, which would be inter-process communication (IPC). There's a few ways to do this, I only have very limited experience with this sort of stuff and I don't know anything about how to do this on Windows, but on Linux, I would probably put the images in a shared memory section or send them over with sockets or pipes. I don't really know which of those approaches is appropriate for your particular problem, but here's a really good guide for Linux IPC: http://beej.us/guide/bgipc/output/html/singlepage/bgipc.html If you're using a shared memory segment, you'll probably have to look at how to synchronize access to it as well, since you don't want process A to overwrite the image as process B is reading it, for instance.I'm trying to do something I've never done before with programming.
Basically I have a program that uses a webcam and does something to the image captured. While that program is running, I want another program to do something else with the images captured. The problem is that the programs can't use the webcam at the same time.
What I want to do is have an intermediary program take the images in memory and pass them off to the appropriate programs to use. When calling any image processing program, it will look to see if that intermediary program is running (if it's not start it) and then automatically get the frames captured with the camera.
I've been looking at popen(), but I'm a little confused. Basically the intermediary program would get the image and put it in a struct (it's in C), and I need to use that struct in the image processing program. How would I return that struct from the intermediary program?
If anyone could explain how to do this at a higher level, I would appreciate it. Definitely don't want someone to have to spell it out, but if you could point me somewhere with how to do it I would be very grateful!
It sounds like what you want to do is capture the images, process them in program A, then send them over to program B, which does something else with them, which would be inter-process communication (IPC). There's a few ways to do this, I only have very limited experience with this sort of stuff and I don't know anything about how to do this on Windows, but on Linux, I would probably put the images in a shared memory section or send them over with sockets or pipes. I don't really know which of those approaches is appropriate for your particular problem, but here's a really good guide for Linux IPC: http://beej.us/guide/bgipc/output/html/singlepage/bgipc.html If you're using a shared memory segment, you'll probably have to look at how to synchronize access to it as well, since you don't want process A to overwrite the image as process B is reading it, for instance.
^^ Yes, of course you can ask questions.
Is this an okay place to post help on programs I may be currently working on? I don't want to bog down off topic with help threads anymore.
double [] data = new double [100];
for (int i = 0 ; i < data.length; i++) {
data[i] = 1.0;
Does anyone have a good way of explaining how to do this in java?
You can initialize the elements of an array using a for loop:
I am having trouble wrapping my head around this.Code:double [] data = new double [100]; for (int i = 0 ; i < data.length; i++) { data[i] = 1.0;
Where it says int i = 0 is that saying at position 0 in the index? also what does mean?
In Java a For Loop is similar to a While Loop, except that it has three parameters - initialization of a index/counter variable, a condition to continue the loop, and then an increment. So basically what's happening is this: an index is created with the variable i, and set to zero. Each loop will test the condition "i < data.length" which means the loop will continue until it has either incremented through every element in the array or met a certain goal/requirement/whatever within the loop (but not in this case since we are simply assigning a value to each element) and lastly "i++" is the increment amount. In this case, incrementing the index by a value of 1.
data is the position in the array. So what's happening step by step is from the beginning i = 0. So the first pass through the loop the first element in the array ( data[0] ) will be set to "1.0". The body of the loop will complete and so the For loop will then increment the index by 1, then test the condition again. Since 1 IS < data.length, the loop will execute again, setting the second position in the array ( data[1] ) to 1.0.
This will continue until i is no longer less than the length of the array.
String[] BoatNames = {"B.Boat","C.Boat","N.Boat",
"R.Boat","W.Boat","M.Boat"};
for(int x = 0; x<BoatNames.length;x++) {
System.out.println(BoatNames[x]);
Edit: So is this saying, FOR X which is an int of 0, use 0 as the starting point when 0 < the length add 1? Why does print BoatNames[X] print out the list of arguments?
System.out.println(BoatNames[x]);
It's literally saying this:
int x = 0 *The index or counter for the loop. It will be incremented by a certain amount (dictated within the parentheses after "for") each pass through the loop.
The next parameter, in this example, x<BoatNames.length is the condition tested after each pass through the loop. The loop will continue UNTIL this condition is FALSE.
The last parameter is the amount by which you will increment the index (or x in this example) AFTER each execution of the loop body.
In case there is any confusion about what the body of the loop is, it's the statements contained within the curly brackets { }.
So in the second example you provided, the for loop is printing out elements in an array. At the end of each pass (before the index is incremented and condition tested again) the Boat Name at position X in the array will be printed.
Does that make sense?
ah ok, that makes it clearer... but my next issue was how could I use those names to create objects?
I kept getting an error like "SailBoat" cannot be converted to String[].
I have another class called sailboat and I wanted to create an object for each name in the array.
Somehow I feel as though we are doing your homework for you =P
If I understand what you're wanting to do, you'll need to create an array of the object type you want. You can't put these 'Sailboat' objects in a Str Array. Think of objects as a new Data Type you created. Just as you can't put Strings into an array of Integers. Treat it just the same as you would the examples earlier - create the array of those objects.
So for example: (keep in mind, I've only been messing with Java for a few months)
public static void main (String[] args) { // This is your main method
sailBoat[] a = new sailBoat[10]; // Creation of a 10 element array of the type 'sailBoat'.
for ( int i = 0; i < a.length; i++) { // For Loop for 'efficiency'.
a = new sailBoat(); } // Simple Constructor for the objects. It will create a new object at each element, and increment through the array, then finish the loop.
EDIT: If anyone who has more Java experience than I, feel free to correct any incorrect information I provide.
Also added Comments in case you aren't sure what's happening at each step.
http://stackoverflow.com/questions/3255/big-o-how-do-you-calculate-approximate-itI just did an online interview programming problem for a company looking to hire and I'm pretty sure I fucked up the problem itself but I'm here to ask about something they've asked me to answer and I had no clue.
How does one determine the space and time complexity of a programming solution? Back in college we went over Big O notation but I don't recall talking about how to calculate it for a program.
just started c programming and i find this memory allocation stuff very difficult to understand...
does anyone know if there are any good resources to learn this stuff?
i'm more of a visual learned type of guy so if there are any videos or diagrams i would appreciate it.