Adding some addtional work by the child process
authorjlance <jlance@9a892ef4-8035-4e6e-bfcf-8e83c02283af>
Sat, 26 Nov 2011 22:40:26 +0000 (22:40 +0000)
committerjlance <jlance@9a892ef4-8035-4e6e-bfcf-8e83c02283af>
Sat, 26 Nov 2011 22:40:26 +0000 (22:40 +0000)
Signed-off-by: Jeff Lance <j-lance1@ti.com>
oprofile_example/signal_parent.c

index a028722e6b7f40cf76d66e0f2b317cb8aadd68e7..6d47ad0620d798714d85d528b1935fbaf485b11a 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include <unistd.h> 
 #include <stdlib.h>
+#define BUF_SIZE (4096*256)
 
 volatile static int signal_parent = 0;
 
@@ -33,13 +34,30 @@ void mysig(int sig)
 int main()
 {
     int pid;
+    int sum;
+    char * buf;
+    int i,j;
 
     printf("child process starting\n");
 
     if((pid = fork()) == 0) {
+      buf = (char *) malloc(BUF_SIZE);
+      if(buf == NULL)
+      {
+        exit(1);
+      } 
+      for(j=0;j<10;j++)
+      {
+        for(i=0;i<BUF_SIZE;i++)
+        {
+          buf[i] = i;
+          sum = (int)buf[i];
+        }
+      }
     // Child process
-        sleep(10);
+        sleep(9);
     // Wake up parent process with a SIGALRM
+        free (buf);
         kill(getppid(), SIGALRM);
         exit(0);
     }