No longer able to max CPU [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I've been programming normally using an AMD 1100 6 core chip. Previously (using the same code) I was able to max out all CPU's (6 threads)
Now, the same code is doing this (still 6 threads):
Before, I was able to get them right to 100% (all 6 cores would go straight up and draw straight lines right across the top. Now I can't seem to figure why the application isn't maxing out the CPU cores, even though there are 6 parallel threads, and the same code used to max out the CPU just a day ago.
I'm running no extra processes, and am doing nothing generally different.
I'm running an extra fan on the CPU as well, and the CPU fan remains calm (which indicates it's not overheating).

First off we need to see the code. Without that I'd be looking to see if you have any synchronisation mechanisms (e.g. mutexes), I/O or use of shared resources that could be giving the CPU some breathing space. If there is any I/O, such as disk, network or other external devices going on, access speed is liable to change from run to run, and the program may be I/O bound rather than CPU bound.

Related

Why the OS allocates more memory than deemed necessary for a small sized executable? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Ok so I wrote this minimal C code and complied it to an executable in release mode
1.void main()
2.{ for(;;); } //this is here to make the app hang.
The executable file size itself is 6kb, I didn't include any headers. Even if the entire exe file gets copied to the ram, apparently it shouldn't occupy more than 7 kb, nevertheless the OS allocates 320 kb, why is that? I'm using windows.
It seems like you're confused and mixing a wide variety of concepts. Let me try to explain:
That program is very clearly an infinite loop which explains why it doesn't end (or what you call "hang").
The compiler/linker still need to write a valid executable for your OS, and this involves a bunch of headers and stuff, which could be easily consuming 6kb.
320kb in a mainstream OS at this point in time seems like almost nothing and it can mainly be OS overhead. It is hard to say more without knowing what OS.
I strongly encourage you to disassemble your code. Another option is to play with your compiler options to optimize for executable size. I think the bottom line is that you're expecting that since your program doesn't do anything useful its size should be zero, and this is an unreasonable expectation.

Multithreaded Webserver in C++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to do a multithreaded Webserver with scheduling and synchronization in C++.This is an assignment problem and I am not asking the code.I have done till the socket connection in server but I dont know how to proceed.I just want some hints or flow for the program.
Here are the few questions I have
1) I have done till socket accept().So when new connection comes I have to fork() and then close the connections of the child process.Is that right?
2) How must I make sure the program is synchronized wth so many threads running?
3) I must have 2 thread pools.1 pool of workers and in the other 2,1 each for acepting connection and inserting the request to ready queue.How can this be done?
I am not asking the code.I just need some hints and guidance.Thanks a lot.
Very interesting course work , if you get you head around this one a lot of concepts will become clear namely concurrency and one of its major use cases I.e. networking!
I used the following article myself to get a quick summary of my options in network concurrency in Linux
http://m.linuxjournal.com/content/three-ways-web-server-concurrency?page=0,0
This article give very high level intros to concepts tha thou will need like copy on write for forked processes and as a result separate address spaces negating sync in certain cases, once you have read this you will have more specific question that you can as once you start getting your hands dirty starting with the code in this article.

How can I access the first 1MB of RAM in Windows programming (Protected Mode)? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How can I access the first 1 MB of RAM directly in Windows programming (Protected Mode)?
For example to write to the video part.
Can I use DPMI to solve all problems?
No, a regular (=user-mode) application can't access directly the physical address space (the address space each application sees is a virtual address space, managed by the OS via the MMU). The whole point of having an operating system is to abstract the hardware details and present to applications a clean programmatic interface, if you want to draw onscreen you should use the graphic libraries provided by Windows (GDI, DirectX).
You can access almost any hardware resource if you write a driver that runs in kernel mode, but if you don't follow carefully the rules of Windows kernel-mode programming you are probably going to make the whole system crash with a BSOD in no time.
If you are talking about video RAM and DPMI I suppose you are coming from some book/tutorial about DOS-style programming (or even without any operating system at all); keep in mind that almost nothing of that stuff is applicable in the context of any modern operating system, because it's not only your code that is running, so you must cooperate and follow the rules/use the APIs of the OS.

how to use video memory as standard memory storage? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I would use video memory on video board (256mb) as a standard memory for storing random values. I know very little about video graphics but i know that one approach is to just make 'models' or other video graphics objects storing my values, thus the video board thinks it processes video images or something this way. But is there another approach?
good article is http://en.gentoo-wiki.com/wiki/Using_Graphics_Card_Memory_as_Swap
that how linux has implemented it. Looks like i need to write windows device driver for graphics subsystem to access video memory.
MS resource about video memory: http://blogs.msdn.com/b/tmulcahy/archive/2009/02/11/windows-and-video-memory.aspx
This is a worse idea than you can possibly comprehend, but sure, you can always allocate a texture with DirectX and set it to be put in video memory only, write stuff in it, then at some later time lock it and read your data back out.
Good luck achieving a fifth of the speed you would by using normal system memory however.

get instant energy consumption [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I am looking to get instant energy consumption, in shell or C++
any ideas ?
Thanks
Your question could do with a bit more detail, but if I understand you correctly a program named Joulemeter does this the following way:
Joulemeter estimates the energy usage
of a VM, computer, or software by
measuring the hardware resources (CPU,
disk, memory, screen etc) being used
and converting the resource usage to
actual power usage based on
automatically learned realistic power
models.
That is one way to go. If you're just doing this for your own project, I guess you could throw together some hardware that measured from the wall socket and gave you the data that way. Maybe something like that exists already.
Well, if you have a Laptop you could use the answer presented for this similar question:
/usr/sbin/system_profiler SPPowerDataType | grep Wattage