Upload batch 346 of 407
Browse files- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/MakeFiles.pdf +3 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/Makefile_Macros.pdf +3 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/Makefile_Macros_Names.pdf +3 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice1.c +7 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice2.c +24 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice3.c +17 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice4.c +26 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice5.c +12 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice6.c +30 -0
- שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 9 - Semaphores/ipc4.c +48 -0
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/MakeFiles.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d5d6ff8a12f57a7da84f00560e9aa7b3d72cba7b9385fa5bc03f00ef82436b29
|
| 3 |
+
size 353834
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/Makefile_Macros.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2d68a7455890dcb8428e11c29dafd9f1764c494ebf234878039e7636b690d2ac
|
| 3 |
+
size 186
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 7 - MAKEFILES/Makefile_Macros_Names.pdf
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ad2ff47f22d0128804a20ba90a400c96b863a8ab1f11809409c19b613186baa4
|
| 3 |
+
size 325
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice1.c
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <unistd.h>
|
| 2 |
+
|
| 3 |
+
void main()
|
| 4 |
+
{
|
| 5 |
+
nice(4);
|
| 6 |
+
while(1){};
|
| 7 |
+
}
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice2.c
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <unistd.h>
|
| 3 |
+
#include <sys/time.h>
|
| 4 |
+
#include <sys/resource.h>
|
| 5 |
+
|
| 6 |
+
void main()
|
| 7 |
+
{
|
| 8 |
+
int pri;
|
| 9 |
+
|
| 10 |
+
pri = getpriority ( PRIO_PROCESS , getpid() );
|
| 11 |
+
printf ("1.The nice/priority is %d\n", pri );
|
| 12 |
+
|
| 13 |
+
nice(3);
|
| 14 |
+
|
| 15 |
+
pri = getpriority ( PRIO_PROCESS , getpid() );
|
| 16 |
+
printf ("2.The nice/priority is %d\n", pri );
|
| 17 |
+
|
| 18 |
+
nice(5);
|
| 19 |
+
|
| 20 |
+
pri=getpriority ( PRIO_PROCESS , getpid() );
|
| 21 |
+
printf ("2.The nice/priority is %d\n", pri );
|
| 22 |
+
|
| 23 |
+
while (1) {}
|
| 24 |
+
}
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice3.c
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <unistd.h>
|
| 3 |
+
#include <sys/time.h>
|
| 4 |
+
#include <sys/resource.h>
|
| 5 |
+
|
| 6 |
+
void main()
|
| 7 |
+
{
|
| 8 |
+
int pri;
|
| 9 |
+
int res =0;
|
| 10 |
+
|
| 11 |
+
res = setpriority( PRIO_PROCESS , getpid() , 10 );
|
| 12 |
+
printf ( "1.res number is %d\n" , res);
|
| 13 |
+
pri = getpriority ( PRIO_PROCESS , getpid() );
|
| 14 |
+
printf ( "1.The nice/priority is %d\n" , pri );
|
| 15 |
+
|
| 16 |
+
while (1) {};
|
| 17 |
+
}
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice4.c
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <unistd.h>
|
| 3 |
+
#include <errno.h>
|
| 4 |
+
#include <sys/time.h>
|
| 5 |
+
#include <sys/resource.h>
|
| 6 |
+
|
| 7 |
+
void main()
|
| 8 |
+
{
|
| 9 |
+
int pri;
|
| 10 |
+
int user_id;
|
| 11 |
+
int res = -1;
|
| 12 |
+
|
| 13 |
+
user_id = getuid();
|
| 14 |
+
|
| 15 |
+
printf("the user id is %d\n",user_id);
|
| 16 |
+
|
| 17 |
+
res = setpriority( PRIO_USER , user_id , 4 );
|
| 18 |
+
|
| 19 |
+
printf("The return value is %d, error no is %d. user id is %d\n",res,errno,user_id);
|
| 20 |
+
|
| 21 |
+
pri = getpriority ( PRIO_USER , user_id );
|
| 22 |
+
|
| 23 |
+
printf ( "Priority is %d for user is %d\n" , pri, user_id );
|
| 24 |
+
|
| 25 |
+
while (1) {};
|
| 26 |
+
}
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice5.c
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <unistd.h>
|
| 3 |
+
#include <sys/time.h>
|
| 4 |
+
#include <sys/resource.h>
|
| 5 |
+
|
| 6 |
+
void main()
|
| 7 |
+
{
|
| 8 |
+
int pri;
|
| 9 |
+
|
| 10 |
+
pri = getpriority ( PRIO_USER , getuid() );
|
| 11 |
+
printf ( "%d\n" , pri );
|
| 12 |
+
}
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 8 - NICE/nice6.c
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <unistd.h>
|
| 2 |
+
#include <sys/time.h>
|
| 3 |
+
#include <sys/resource.h>
|
| 4 |
+
#include <stdio.h>
|
| 5 |
+
|
| 6 |
+
int main()
|
| 7 |
+
{
|
| 8 |
+
int which, prio=10,prio_res;
|
| 9 |
+
id_t who=getpid();
|
| 10 |
+
|
| 11 |
+
which = PRIO_PROCESS;
|
| 12 |
+
|
| 13 |
+
prio_res = getpriority(which, who);
|
| 14 |
+
printf("1. Nice value = %d\n", prio_res);
|
| 15 |
+
|
| 16 |
+
setpriority(which, who, prio);
|
| 17 |
+
printf("2. Try to set the Nice value to = %d\n", prio);
|
| 18 |
+
|
| 19 |
+
prio_res = getpriority(which, who);
|
| 20 |
+
printf("2. Nice value = %d\n", prio_res);
|
| 21 |
+
|
| 22 |
+
prio=19;
|
| 23 |
+
setpriority(which, who, prio);
|
| 24 |
+
printf("3. Try to set the Nice value to = %d\n", prio);
|
| 25 |
+
|
| 26 |
+
prio_res = getpriority(which, who);
|
| 27 |
+
printf("4. Nice value = %d\n", prio_res);
|
| 28 |
+
|
| 29 |
+
return 0;
|
| 30 |
+
}
|
שנה ב/סמסטר ב/מערכות הפעלה/תרגולים/תרגול 9 - Semaphores/ipc4.c
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#include <stdio.h>
|
| 2 |
+
#include <unistd.h>
|
| 3 |
+
#include <sys/types.h>
|
| 4 |
+
#include <sys/ipc.h>
|
| 5 |
+
#include <sys/sem.h>
|
| 6 |
+
|
| 7 |
+
union semun
|
| 8 |
+
{
|
| 9 |
+
int val; /* Value for SETVAL */
|
| 10 |
+
struct semid_ds *buf; /* Buffer for IPC_STAT, IPC_SET */
|
| 11 |
+
unsigned short *array; /* Array for GETALL, SETALL */
|
| 12 |
+
struct seminfo *__buf; /* Buffer for IPC_INFO /* (Linux-specific) */
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
int main()
|
| 17 |
+
{
|
| 18 |
+
int semid;
|
| 19 |
+
union semun semarg;
|
| 20 |
+
int i;
|
| 21 |
+
struct sembuf sops[1];// see declaration of sembuf in Google
|
| 22 |
+
|
| 23 |
+
semid = semget ( IPC_PRIVATE , 1 , IPC_CREAT | IPC_EXCL);//0666 );// 1- create only one semaphore
|
| 24 |
+
printf("1. The Semaphore ID is %d\n",semid);
|
| 25 |
+
semarg.val = 1;
|
| 26 |
+
semctl ( semid , 0 , SETVAL , semarg );// 0 - only one semaphore . SETVAL - the command
|
| 27 |
+
sops->sem_num = 0;// only one semaphore
|
| 28 |
+
sops->sem_flg = 0;// no special options
|
| 29 |
+
if ( fork() == 0 ) {
|
| 30 |
+
sops->sem_op = -1; // try to decrease the sem. from 1 to 0
|
| 31 |
+
semop ( semid , sops , 1 );// 1- only one operation . operate the decrease
|
| 32 |
+
printf ("2. Child : semapore is locked now\n");
|
| 33 |
+
sleep( 8 );//sleep for 8 seconds
|
| 34 |
+
sops->sem_op = 1; // increase the sem. from 0 to 1
|
| 35 |
+
semop ( semid , sops , 1 ); // operate the increase
|
| 36 |
+
printf("3. Child is finished\n");
|
| 37 |
+
}
|
| 38 |
+
else {
|
| 39 |
+
sleep( 4 );//sleep for 4 seconds
|
| 40 |
+
printf("4. Parent is waiting for child to release semaphore\n");
|
| 41 |
+
sops->sem_op = -1;
|
| 42 |
+
semop ( semid , sops , 1 );
|
| 43 |
+
printf("5. Parent finished\n");
|
| 44 |
+
semctl ( semid , 0 , IPC_RMID , semarg ); // The last argument is not really needed
|
| 45 |
+
}
|
| 46 |
+
return 0;
|
| 47 |
+
}
|
| 48 |
+
|