Develop a small program in C or java using system calls (e.g. fork(), waitpid(), exit(), kill(), ..)\nthat does the following:\na)a parent process creates a child process that prints its PID. \n\nb)the child creates a grandchild and sleeps 120 seconds. \n\nc)the grandchild immediately exits.\n\nd)the parent sleeps for 60 seconds and then kills all the processes. \n\nThank you \n:)
138013
This ought to give you a pretty good start.  You'll\nwant to remove the lines which print "DEBUG", but\nthey're handy for watching it execute.\n\nI didn't use waitpid() because I didn't see that it\nwas needed by the 4 requirements (since the child\nand parent both block on sleep() calls.\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <sys/types.h>\n#include <unistd.h>\n#include <sys/types.h>\n#include <signal.h>\n\nint\nmain(int argc, char* argv[])\n{\n  fprintf(stderr, "DEBUG: In parent: creating child ...&#92;n");\n\n  /* part "a": Creating the child */\n  pid_t child_pid = fork();\n  if (child_pid > 0) { /* child */\n\n    /* part "a": child prints its PID */\n    pid_t grandchild_pid, my_pid = getpid();\n    fprintf(stderr, "In child: pid == %ld&#92;n", (long)my_pid);\n\n    /* part "b": create a grandchild */\n    if ((grandchild_pid = fork()) > 0) {  /* grandchild */\n      /* part "c": the grandchild immediately exits */\n      fprintf(stderr, "DEBUG: In grand child: exiting...&#92;n");\n      exit(0);\n    }\n    else if (grandchild_pid == 0) { /* still in child */\n      /* part "b": sleep 120 seconds */\n      fprintf(stderr, "DEBUG: In child: sleeping 120...&#92;n");\n      sleep(120);\n      exit(0);\n    }\n    else { /* error */\n      perror("fork in child");\n      exit(-1);\n    }\n\n  }\n  else if (child_pid == 0) {  /* parent */\n    /* part "d": the parent sleeps for 60 seconds */\n    fprintf(stderr, "DEBUG: In parent: sleeping 60...&#92;n");\n    sleep(60);\n\n    /* part "d": the parend kills all processes */\n    fprintf(stderr, "DEBUG: In parent: killing child ...&#92;n");\n    kill(child_pid, SIGKILL);\n    exit(0);\n  }\n  else {\n    perror("fork in main");\n    exit(-1);\n  }\n  exit(0);\n}
37396
well, you didn't specify a language so here's korn shell:\n\n#! /bin/ksh\nread c\nTEMP=1\nwhile [ $TEMP -lt $c ]; do\n  echo "**********************************" | cut -c1-$TEMP\n  let "c += 1"\ndone\n\nmy c++ is a bit rusty, but the loop would look like this:\n\nwhile ( c = 1; c <= count ; c++ )\n{\n  while ( d = 1; d <= c; d++ )\n  {\n    cout << "*";\n  }\n  cout << endl;\n}\n\nhope this helps :-)
603556
unsigned int delaytimer = 0;\nvoid __stdcall delaytime(HWND, UINT, UINT, ULONG)\n{\n  if (delaytimer) {\n    KillTimer(0, delaytimer);\n    delaytimer=0;\n  }\n  AfxMessageBox("Hi!");\n}\n\nint main()\n{\n  delaytimer = SetTimer(0, 0, 10000 /* milliseconds */, delaytime);\n}
56000
There is no compiler-independent support for multi-threading in C. That is not to say you can't do it, it will just be different with each compiler.\n\nI personally use Borland C++ Builder (HUGE fan of Builder), and there is a "thread" class that you can use for multi-threaded applications. It is a bit of work to get your first time up and running, but now it takes me about 2 minutes to change something from main thread to its own thread in Borland.
188813
here...I'll tell you what to write and you write it...\n\n/* outline the program */\n\n// void main()...etc..\n\n/* define your variables */\n/* you'll need a pair of char pointers */\n/* and some numbers to hold converted values */\n\n\n/* input the first binary as a string */\n\n/* input the second binary as a string */\n\n/* convert them to decimal */\n\n/* add them */\n\n/* fprintf them */\n\n/* end program */\n\n\nthat's all.\nI write all my programs in commented logic first then fill in the blanks so that it does what I meant.  When I'm done, the program follows the flow and is already commented for the next person to follow.
205086
For existing programs that do this, see PSLIST and ProcessExplorer.  \n\nTo write your own in C++, see this great Code Project article by Ahmed Yassin: http://www.codeproject.com/threads/Tasks.asp\n\nA comment at the end of the article mentions 3 other ways to do it as well:\n\n1. ToolHelp \n2. PSAPI\n3. Read Registry (check platform SDK sample PView)\n4. some function exported by ntdll.dll \n\nAlso see the MSDN help on the functions used in Ahmed's article.\n\nGood luck!
393322
hmmm..... media player? boohh......\ndns server? boooh....\nit's so lame.\n\nif you want to find a 'bunch' of inspiration for your project, goto this site\nhttp://sourceforge.net/\n\nbtw, if you have decide what program you want to build, post it in your comment later.
630553
Here is something I came up with quickly ( not fully complete, I will leave that to you ! ) \n\nThis quick bit of code will give you a start ( hopefully and no recursion ).\n\nPlease note that this is not complete and you will get a memory leak in swap function ( easily fixed btw ! ).\n\n#include "stdafx.h"\n#include "stdio.h"\n#include "string.h"\n\nvoid manipulate( char* pString, int index );\nchar* swap( char* pString, int pos );\n\nchar pod[255];\n\n\nint main(int argc, char* argv[])\n{\n\n  char* p = "abc";\n  memcpy( pod, p, strlen( p ) );\n  for( int i = 0; i < strlen( p ); i ++ )\n  {\n    manipulate( pod, strlen( p ) );\n  }\n  return 0;\n}\n\n\nvoid manipulate( char* pString, int index )\n{\n  int i = 1;\n  char* p;\n  p = pString;   \n  while( index > 1 ) \n  {\n    p = swap( p, i );\n    index--;\n    i++;\n    memcpy( pod, p, strlen( pString ) );\n    printf( "%s&#92;n", p );\n  }\n}\n\nchar* swap( char* pString, int pos )\n{\n  char* p = new char[ strlen(pString) + 1 ];\n  memset( p, '&#92;0', strlen( pString ) + 1);\n  memcpy( p, pString, strlen( pString ) + 1 );\n  char temp = p[pos];\n  p[pos] = pString[pos-1];\n  p[pos-1] = temp;\n  return p;\n}
365392
I note that no one has attempted to answer this so far.\n\nPerhaps it's because you have not given us enough information.  What are you trying to do?\nWhat program?
610620
try this very interesting and A grade project How to build your own 8051 Development System\n\nhttp://www.rentron.com/project02.htm
568732
#include <stdio.h>\n#include <dos.h>\n#include <conio.h>\n\n/********************************************/\n/*This program set the parallel port outputs*/\n/********************************************/\n\nvoid main (void)\n{\nclrscr();             /* clear screen */\noutportb(0x378,0xff); /* output the data to parallel port */\ngetch();              /* wait for keypress before exiting */\n}\n\njust check here you can get all info http://www.epanorama.net/circuits/parallel_output.html
37921
im sorry i tried my best. but now im sleepy. hope someone can answer this for u.\ngudluck\n\ndo u have example? send it to freakcreator@yahoo.com maybe i can do somthing about it. and send this question too.
4397
Well following link can make a good resource for your need, read the second section :\n\nhttp://cs.dal.ca/~koul/
153742
A lecturer once gave me some advice.  He was on an interview panel and gave some code to a potential candidate.  He asked what was wrong with the code - as it turns out there was nothing wrong with it, but he wanted to see how the candidate deals with logical progession in program flow.  That said, I have added some links to a sites you may find useful as a starting point . . .
73220
I would suggest Activity Monitor. It is a real time PC monitoring system. It has two parts, client and server. The great thing about it is, it can be installed remotely to PCs in LAN (Win NT/2000 and XP).\n\nIt is able to log keystrokes, Screens, every thing. Any program canbe run or close remotely by it. Reports r also great.\n\nI think this is the one u r looking for.\n\nHope ur sons r not doing anything wrong.\n\nAll the best.
180736
Download lcc-win32. It comes with a very good C tutorial and you can try things with the IDE that makes things much easier for a newbie. Other than that just go google and search for C Tutorials and free on-line books. There are a lot of these on the web.
156470
Thank you from a mom's viewpoint.  I think it's lack of supervision.  The computer may be in an area of the home that's is shut off from the adults.  Also I don't think some parents know what type of questions are being asked.