Upload batch 345 of 407
Browse files- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig4.c +27 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig5.c +8 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig6.c +7 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig7.c +20 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig8.c +34 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig9.c +41 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/Makefile.pdf +3 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/functionsLab1.c +26 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/functionsLab1.h +8 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/main.c +16 -0
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig4.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 <unistd.h>
|
| 6 |
+
|
| 7 |
+
void funct(int sig);
|
| 8 |
+
|
| 9 |
+
int main()
|
| 10 |
+
{
|
| 11 |
+
int pid;
|
| 12 |
+
|
| 13 |
+
signal(SIGSEGV, funct);
|
| 14 |
+
pid = getpid();
|
| 15 |
+
kill(pid,SIGSEGV);
|
| 16 |
+
|
| 17 |
+
return 0;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
void funct(int sig)
|
| 21 |
+
{
|
| 22 |
+
printf("inside funct() . Interrupt/Signal handler \n");
|
| 23 |
+
printf("Segmentation is %d\n",sig);
|
| 24 |
+
exit(1);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig5.c
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <signal.h>
|
| 2 |
+
|
| 3 |
+
void main()
|
| 4 |
+
{
|
| 5 |
+
sigblock(sigmask(SIGSEGV));
|
| 6 |
+
while(1);
|
| 7 |
+
}
|
| 8 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig6.c
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
int main()
|
| 2 |
+
{
|
| 3 |
+
int a = 1/0;
|
| 4 |
+
|
| 5 |
+
return 0;
|
| 6 |
+
}
|
| 7 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig7.c
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <signal.h>
|
| 4 |
+
|
| 5 |
+
void funct(int sig);
|
| 6 |
+
|
| 7 |
+
int main()
|
| 8 |
+
{
|
| 9 |
+
signal(SIGFPE, funct);
|
| 10 |
+
int a = 1/0;
|
| 11 |
+
|
| 12 |
+
return 0;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
void funct(int sig)
|
| 16 |
+
{
|
| 17 |
+
printf("You tried to divide a number by zero\n");
|
| 18 |
+
exit(1);
|
| 19 |
+
}
|
| 20 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig8.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 |
+
if ( fork() == 0 )
|
| 15 |
+
{
|
| 16 |
+
/* This is the son */
|
| 17 |
+
pid=getppid();
|
| 18 |
+
kill(pid,SIGUSR1);
|
| 19 |
+
}
|
| 20 |
+
else
|
| 21 |
+
{
|
| 22 |
+
/* This is the parent */
|
| 23 |
+
signal(SIGUSR1, father_function);
|
| 24 |
+
wait(&s);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
return 0;
|
| 28 |
+
}
|
| 29 |
+
void father_function(int sig)
|
| 30 |
+
{
|
| 31 |
+
printf("Parent got a signal from his son.sig %d\n",sig);
|
| 32 |
+
exit(1);
|
| 33 |
+
}
|
| 34 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 5 ו-6 - Signals - דוגמאות קוד/sig9.c
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <stdlib.h>
|
| 3 |
+
#include <signal.h>
|
| 4 |
+
#include <sys/types.h>
|
| 5 |
+
#include <unistd.h>
|
| 6 |
+
#include <sys/wait.h>
|
| 7 |
+
#include <sys/types.h>
|
| 8 |
+
#include <sys/ipc.h>
|
| 9 |
+
#include <sys/shm.h>
|
| 10 |
+
#include <string.h>
|
| 11 |
+
#include <sys/sem.h>
|
| 12 |
+
|
| 13 |
+
void child_function();
|
| 14 |
+
|
| 15 |
+
void main()
|
| 16 |
+
{
|
| 17 |
+
int pid,s;
|
| 18 |
+
|
| 19 |
+
if ( ( pid=fork() ) == 0 )
|
| 20 |
+
{
|
| 21 |
+
/* This is the son */
|
| 22 |
+
printf("This is the child. pid=%d\n",getpid());
|
| 23 |
+
signal(SIGUSR1, child_function);
|
| 24 |
+
while(1) {};
|
| 25 |
+
}
|
| 26 |
+
else
|
| 27 |
+
{
|
| 28 |
+
/* This is the parent */
|
| 29 |
+
sleep(3);
|
| 30 |
+
printf("This is the parent. pid of child is %d\n",pid);
|
| 31 |
+
kill(pid,SIGUSR1);
|
| 32 |
+
wait(&s);
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
void child_function(int sig)
|
| 37 |
+
{
|
| 38 |
+
printf("Child : I got a signal from my parent.sig is %d\n",sig);
|
| 39 |
+
exit(1);
|
| 40 |
+
}
|
| 41 |
+
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/Makefile.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7009201de2fcafb749365cbcd5c8971ff8c4d94effa3d7f205181ebbb90a6df2
|
| 3 |
+
size 222
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/functionsLab1.c
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
|
| 3 |
+
#include "functionsLab1.h"
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
void printTriangle(int basis)
|
| 7 |
+
{
|
| 8 |
+
int row, i,j,space;
|
| 9 |
+
for (row = 1; row <= basis; row++)
|
| 10 |
+
{
|
| 11 |
+
space = basis - row;
|
| 12 |
+
for (j = 0; j < space; j++)
|
| 13 |
+
printf(" ");
|
| 14 |
+
for (i = 0; i < row; i++)
|
| 15 |
+
printf("*");
|
| 16 |
+
printf("\n");
|
| 17 |
+
}
|
| 18 |
+
printf("\n");
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
void helloWorld()
|
| 22 |
+
{
|
| 23 |
+
|
| 24 |
+
printf("Hello World\n");
|
| 25 |
+
|
| 26 |
+
}
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/functionsLab1.h
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef __FUNCLAB1__
|
| 2 |
+
#define __FUNCLAB1__
|
| 3 |
+
|
| 4 |
+
void helloWorld();
|
| 5 |
+
void printTriangle(int basis);
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
#endif
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/main.c
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include "functionsLab1.h"
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
void main()
|
| 7 |
+
{
|
| 8 |
+
|
| 9 |
+
int basis;
|
| 10 |
+
|
| 11 |
+
helloWorld();
|
| 12 |
+
printf("Please enter a number\n");
|
| 13 |
+
scanf("%d", &basis);
|
| 14 |
+
printTriangle(basis);
|
| 15 |
+
}
|
| 16 |
+
|