Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Improve this question
How can I create an executable that keeps running and shows up in task manager, but does nothing? I need it for a program, I can use every language, or if it already exists it's better.
Thanks.
Here is a C code to do the job, you can use the thread sleep method to decrease the CPU load
#include<stdio.h>
int main()
{
char a;
while((a=getchar())!='z')// to quit the program when z is pressed
{
}
return 0;
}
Create a file with .cmd extension and write this into that file:
:BEGIN
GOTO BEGIN
You can double click on it, and call it from any programming language you want with this like code:
system("/path_to_your_code/your_file.cmd");
Here's a good example in C#
using System;
using System.Threading;
class Program {
static void Main() {
while(true) {
Thread.Sleep(100); // So we don't spam the CPU too much
}
}
}
Another example for an program you actually could quit without too much hassle.
It just waits for you to press Enter. :)
using System;
class Program {
static void Main() {
Console.ReadLine();
}
}
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 months ago.
Improve this question
Same question as Is there any negative performance implication to using local functions in Rust? but for struct.
fn bla() -> PublicStruct {
MyHiddenStruct {bla:String};
let m = MyHiddenStruct{bla: "aa".to_string()};
// some work...
m.into()
}
Edit: Indeed I tried a little benchmark with criterion
innerouterstruct/outer struct
time: [901.16 ps 905.16 ps 910.44 ps]
innerouterstruct/inner struct
time: [901.10 ps 903.89 ps 907.31 ps]
No. The only thing this affects is the visibility of the struct (and its name). Codegen is not affected at all.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I want to understand the implementation of top command in linux ie how it uses the procfs interface for displaying the top running processes.?what sources should i refer.
First, read carefully proc(5). Then study code of procps, and, as commented by tangrs, of unixtop, i.e. top-3.7.tar.gz
For example, your program might do
{ FILE* psf = fopen("/proc/self/statm", "r");
if (psf) {
int progsize = 0;
fscanf(psf, "%d", &progsize);
printf ("program size is %d pages\n", progsize);
fclose(psf);
} else perror("fopen /proc/self/statm");
}
to print its own program size. You could make it a function:
int get_my_program_size(void) {
int progsize = -1;
FILE* psf = fopen("/proc/self/statm", "r");
if (psf) {
fscanf(psf, "%d", &progsize);
fclose(psf);
} else perror("get_my_program_size /proc/self/statm");
return progsize;
}
This is really quick: no disk i/o is involved, since the /proc/ filesystem is a pseudo-filesystem and its file contents are computed on the fly and on demand. These pseudo-files (like /proc/1234/statm or /proc/1234/status etc....) should be read sequentially.
If you want user-mode CPU time, you could parse the 14th field (utime) of /proc/self/stat (or of /proc/1234/stat for the process of pid 1234). I leave that as an exercise to the reader....
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I have some scripts written in proprietary language. I want to know whether there is any language with similar syntax like this ?
PROCEDURE MY_PROC_NAME DO
{
DECLARE VARIABLE ABC AS NUMBER
[ABC] := 123;
IF ([ABC] = 123) THEN
{
WHILE (TRUE) DO
{
}
}
ELSE
{
RETURN
}
#a comment
SomeFunction(123, 456);
CALL ANOTHER_PROCEDURE;
}
Thank you.
That looks a lot like Comal. See http://en.m.wikipedia.org/wiki/COMAL
This is an imperative programming language, with no macro, functional or object-oriented features in the samples provided. It has features borrowed from Pascal (':=') and C ('{}'). The structure is otherwise unremarkable.
There are some distinctive constructs.
PROCEDURE name DO {} to define a procedure (but apparently not a function).
DECLARE VARIABLE name AS type to define a variable.
[ABC] in referring to the contents of a variable.
The lack of a semicolon on the DECLARE line is interesting, but could be a typo.
So, a derivative language probably dating from around the mid to late 1980s. It could even be a dialect of Basic (there were lots of them!).
With some additional code it might be possible to narrow it down further.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Does anyone know of any software like Google Docs, or collabedit that allows you to edit realtime collaboratively and even compile a .cpp or other program over the web?
I haven't used this website, but seems like http://codebunk.com/ does the job.
It doesn't work for Java though.
I know of this website that will compile the code for you:
http://ideone.com/
Unfortunately, I cannot help in the real time editing front.
I wrote a little webapp that does exactly that, i.e. it lets you compile Google Docs documents: http://compiler.m01.eu
You can write C++ code into a Google Document (and do that collaboratively if you like), and then click on a bookmark (provided on the site) to compile your code, which will either start the download of your binary or show a compiler error message.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
how can i handle stack overflow exception in my game it occures when i play the game plz reply asap possible?
Well, to be blunt, you should probably not try to handle a Stack Overflow exception.
In some cases, you can't execute code in response to a stack overflow exception, since that code requires stack space, which is unavailable, hence double-fault.
Instead, you should change the code so as to avoid it completely.
This might mean changing your algorithm to some other algorithm, or possibly implementing the stack-based recursion in your own stack and switch to a loop instead.
try
{
//your work
}
catch(StackOverflowException ex)
{
// handle it
}
Stack overflow is most often related to recursive calls, and not the gc.
GC would throw you an out of memory exception.
public static void main(String args[])
{
try
{
LongRecursiveMethodOrSomethingLikeThat();
} catch(StackOverflowError t) {
// Generic catch// catch(Error e)
// anything: catch(Throwable t)
System.out.println("Error:"+t);
t.printStackTrace();
}