Upload batch 344 of 407
Browse files- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 3 ו-4 - תהליכים_Processes - דוגמאות קוד/8.c +23 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 3 ו-4 - תהליכים_Processes - דוגמאות קוד/9.c +27 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig-tuvia.c +14 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig1.c +9 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig10.c +34 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig11.c +24 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig12.c +28 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig2.c +22 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig3.c +27 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig3b.c +25 -0
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 3 ו-4 - תהליכים_Processes - דוגמאות קוד/8.c
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <sys/types.h>
|
| 4 |
+
#include <sys/wait.h>
|
| 5 |
+
#include <unistd.h>
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
void main()
|
| 9 |
+
{
|
| 10 |
+
int pid,pid1,pid2,status;
|
| 11 |
+
|
| 12 |
+
if ((pid1=fork())==0)
|
| 13 |
+
printf("in child 1\n");
|
| 14 |
+
else
|
| 15 |
+
if ((pid2=fork())==0)
|
| 16 |
+
printf("in child 2\n");
|
| 17 |
+
else
|
| 18 |
+
{
|
| 19 |
+
printf("child 1 finished?\n");
|
| 20 |
+
printf("child 2 finished?\n");
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 3 ו-4 - תהליכים_Processes - דוגמאות קוד/9.c
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <sys/types.h>
|
| 4 |
+
#include <sys/wait.h>
|
| 5 |
+
#include <unistd.h>
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
void main()
|
| 9 |
+
{
|
| 10 |
+
int pid,pid1,pid2,status;
|
| 11 |
+
|
| 12 |
+
if ((pid1=fork())==0)
|
| 13 |
+
printf("in child 1\n");
|
| 14 |
+
else
|
| 15 |
+
if ((pid2=fork())==0)
|
| 16 |
+
printf("in child 2\n");
|
| 17 |
+
else
|
| 18 |
+
{
|
| 19 |
+
pid=wait(&status);
|
| 20 |
+
if (pid==pid1)
|
| 21 |
+
printf("child 1 finished\n");
|
| 22 |
+
if (pid==pid2)
|
| 23 |
+
printf("child 2 finished\n");
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig-tuvia.c
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <signal.h>
|
| 4 |
+
#include <sys/types.h>
|
| 5 |
+
#include <unistd.h>
|
| 6 |
+
|
| 7 |
+
int main()
|
| 8 |
+
{
|
| 9 |
+
abort();
|
| 10 |
+
while (1) {}
|
| 11 |
+
|
| 12 |
+
return 0;
|
| 13 |
+
}
|
| 14 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig1.c
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
int main()
|
| 2 |
+
{
|
| 3 |
+
char *a;
|
| 4 |
+
|
| 5 |
+
*a=0;
|
| 6 |
+
|
| 7 |
+
return 0;
|
| 8 |
+
}
|
| 9 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig10.c
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <signal.h>
|
| 4 |
+
#include <sys/types.h>
|
| 5 |
+
#include <sys/wait.h>
|
| 6 |
+
#include <unistd.h>
|
| 7 |
+
|
| 8 |
+
void father_function(int sig);
|
| 9 |
+
|
| 10 |
+
int main()
|
| 11 |
+
{
|
| 12 |
+
int pid,s;
|
| 13 |
+
|
| 14 |
+
signal( SIGUSR2, father_function);
|
| 15 |
+
if ( fork() == 0 )
|
| 16 |
+
{
|
| 17 |
+
/* This is the son */
|
| 18 |
+
pid=getppid();
|
| 19 |
+
kill(pid,SIGUSR2);
|
| 20 |
+
}
|
| 21 |
+
else
|
| 22 |
+
{
|
| 23 |
+
/* This is the father */
|
| 24 |
+
wait(&s);
|
| 25 |
+
}
|
| 26 |
+
return 0;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
void father_function(int sig)
|
| 30 |
+
{
|
| 31 |
+
printf("Parent : I got signal from my son.sing %d\n",sig);
|
| 32 |
+
exit(1);
|
| 33 |
+
}
|
| 34 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig11.c
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <signal.h>
|
| 4 |
+
|
| 5 |
+
void funct();
|
| 6 |
+
|
| 7 |
+
int main()
|
| 8 |
+
{
|
| 9 |
+
char *a;
|
| 10 |
+
|
| 11 |
+
signal(SIGSEGV, funct);
|
| 12 |
+
signal(SIGSEGV, SIG_DFL );
|
| 13 |
+
|
| 14 |
+
*a=0;
|
| 15 |
+
|
| 16 |
+
return 0;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
void funct(int sig)
|
| 20 |
+
{
|
| 21 |
+
printf("Inside funct() function.sig is %d\n",sig);
|
| 22 |
+
exit(1);
|
| 23 |
+
}
|
| 24 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig12.c
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <signal.h>
|
| 4 |
+
#include <sys/types.h>
|
| 5 |
+
#include <sys/wait.h>
|
| 6 |
+
#include <unistd.h>
|
| 7 |
+
|
| 8 |
+
void funct(int sig);
|
| 9 |
+
|
| 10 |
+
int main()
|
| 11 |
+
{
|
| 12 |
+
int *a=NULL;
|
| 13 |
+
signal(SIGSEGV, SIG_IGN );
|
| 14 |
+
printf("Before Violation. h = %d\n",h);
|
| 15 |
+
*a = 0;
|
| 16 |
+
printf("After Violation\n");
|
| 17 |
+
while(1) {};
|
| 18 |
+
|
| 19 |
+
return 0;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
void funct(int sig)
|
| 23 |
+
{
|
| 24 |
+
printf("in funct() function\n");
|
| 25 |
+
exit(1);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig2.c
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <signal.h>
|
| 4 |
+
|
| 5 |
+
void funct(int sig);
|
| 6 |
+
|
| 7 |
+
int main()
|
| 8 |
+
{
|
| 9 |
+
char *a;
|
| 10 |
+
|
| 11 |
+
signal(SIGSEGV, funct);
|
| 12 |
+
//*a=0;
|
| 13 |
+
printf("The end\n");
|
| 14 |
+
return 0;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
void funct(int sig)
|
| 18 |
+
{
|
| 19 |
+
printf("inside funct(interrupt handler).%d\n",sig);
|
| 20 |
+
exit(1) ;
|
| 21 |
+
}
|
| 22 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig3.c
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <signal.h>
|
| 4 |
+
#include <sys/types.h>
|
| 5 |
+
#include <sys/ipc.h>
|
| 6 |
+
#include <sys/sem.h>
|
| 7 |
+
#include <unistd.h>
|
| 8 |
+
#include <sys/wait.h>
|
| 9 |
+
|
| 10 |
+
void funct(int si);
|
| 11 |
+
|
| 12 |
+
int main()
|
| 13 |
+
{
|
| 14 |
+
printf("Starting the program...\n");
|
| 15 |
+
signal(SIGINT, funct);
|
| 16 |
+
while(1) {};
|
| 17 |
+
|
| 18 |
+
return 0;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
void funct(int sig)
|
| 22 |
+
{
|
| 23 |
+
printf("inside function funct(interrupt handler)\n");
|
| 24 |
+
printf("The interrupt is %d\n",sig);
|
| 25 |
+
exit(1);
|
| 26 |
+
}
|
| 27 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig3b.c
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <signal.h>
|
| 4 |
+
#include <unistd.h>
|
| 5 |
+
|
| 6 |
+
void funct(int si);
|
| 7 |
+
|
| 8 |
+
int main()
|
| 9 |
+
{
|
| 10 |
+
int j;
|
| 11 |
+
signal(SIGINT, funct);//11-SIGSEGV
|
| 12 |
+
for (j=0;j<=3;j++)
|
| 13 |
+
{
|
| 14 |
+
printf("%d\n",j);
|
| 15 |
+
sleep(3);
|
| 16 |
+
}
|
| 17 |
+
return 0;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
void funct(int sig)
|
| 21 |
+
{
|
| 22 |
+
printf("inside function funct(interrupt handler)\n");
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
|