This commit is contained in:
Arnaud NGWALA NGWALA 2023-12-10 15:48:26 +01:00
parent cdbec2b91f
commit 7a18fddeb4
44 changed files with 1977 additions and 10 deletions

3
SCR1.1/Meetgenda.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
Dernier_Repertoire=$pwd
cd ~/public_html/Meetgenda && git pull && cd $Dernier_Repertoire

20
SCR1.1/find_bigger_files.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
# A simple program to find
# in the active directory
# the bigger files.
if [[$# -ne 1]]
then
echo "Usage : ./$0 <FOLDER_NAME>"
exit
fi
ls -l $1 > $($1_files.txt)
bigger_file=0
for ligne in $(<$1_files.txt)
do
echo "$ligne"
done
exit

View File

@ -0,0 +1,22 @@
.equ SYS_EXIT ,93
.data
int: .word -1
.text
.globl _start
_start:
adr x4, int
ldr w3, [x4]
sxtw x2, w3
mov x0, #0
loop: cbz x2, exit
tbz x2, #0, next
add x0, x0, x1
next: lsr x2, x2, #1
mov x1, 1
b loop
exit: mov x0, #0
mov w8,#SYS_EXIT
svc #0x0
.end

21
SCR2.1/number-xeight.s Normal file
View File

@ -0,0 +1,21 @@
.equ SYS_EXIT, 93
.data
int : .word 12
.text
.globl _start
_start : adr x1, int
ldr w0,[x1] //n est dans w0
mov w1, #0 //res est dans w1
mov w2, #1 //i est dans w2
bcl: cmp w2, w0
b.gt fin
add w1,w1,w2
add w2,w2,#1
b bcl
fin: mov x0,x1
mov w8, #SYS_EXIT
svc #0
.end

View File

@ -0,0 +1,178 @@
DNSSEC validation turned on by default as of BIND 9.8.1
-------------------------------------------------------
As of version 9.8.1.dfsg-1, BIND ships with DNSSEC validation turned on
by default. As the keys get changed over time, this means that a fresh
install of BIND will require that the admin manually upgrade bind.keys
to account for the change, before BIND will be able to resolve hosts in
DNSSEC validated zones.
Upgrading from BIND 8.X:
-----------------------
If you are upgrading an authoritative server from BIND 8.X, please install
the bind9-doc package and read /usr/share/doc/bind9-doc/misc/migration.gz,
which contains a set of notes from the BIND maintainers on what changed
that is likely to need your attention during an upgrade.
Upgrading from earlier bind9 packages:
-------------------------------------
If you installed an early version of the Debian bind9 packages, prior to
version 1:9.2.0-2 to be more precise, you may have an /etc/bind/rndc.conf
configuration file still on your system. There's nothing wrong with that,
and if you've explicitly configured keys for using rndc you may well want to
leave things exactly as they are!
However, since 9.2.0 BIND 9.X has supported an rndc.key file that both named
and rndc will read to obtain a shared key for rndc use against a daemon on
the same host. The rndc-confgen program will easily create a suitable key
file. To take advantage of this mechanism, you may want to:
remove the /etc/bind/rndc.conf file
remove the rndc key specification in the /etc/bind/named.conf file
rndc-confgen -r /dev/urandom -a
Alternatively, you can 'purge' the bind9 packages and reinstall them and you
will end up with the new behavior since it is now the default.
This is more secure than using a static key that isn't generated on a per-host
basis, and is an easy alternative to more complex key schemes if you only need
to use rndc to talk to named on the same host.
Known Issues:
------------
I've had a report that lwresd, at least, fails to work with some recent 2.5
kernels. If you see something in your logs like
loading configuration from '/etc/bind/lwresd.conf'
none:0: open: /etc/bind/lwresd.conf: permission denied
Try rebuilding with --disable-linux-caps added to the configure call in the
rules file. I'm hoping this is a temporary problem in the 2.5 kernel series,
but we'll see.
Configuration Schema:
--------------------
The Debian BIND package ships with a config that will work for the majority
of leaf servers with no user input required.
The named configuration file named.conf is located in /etc/bind, so that all
static configuration files relating to bind are in one place. If you really
don't want named.conf in /etc/bind, then the best way to handle it is probably
to replace /etc/bind/named.conf with a symlink to the location you want to use.
You could also use an option to named in the init.d script, but that only works
for named, not for things like ndc.
Zone data files for the root servers, and the forward and reverse localhost
zones are also provided in /etc/bind.
The working directory for named is now /var/cache/bind. Thus, any transient
files generated by named, such as database files for zones the daemon is
secondary for, will be written to the /var filesystem, where they belong.
To make this work, the named.conf provided uses explicitly fully-qualified
pathnames to reference the files in /etc/bind.
Unlike previous BIND packages for Debian, the named.conf and provided db.*
files are tagged as conffiles. Thus, if you just want a "caching mostly"
server configuration for a server that does not need to be authoritative for
anything else, you can run the provided configuration as-is. If you want to
hack on named.conf, or even the init.d fragment, you can feel free to. Future
package upgrades will treat your configuration changes sanely, as all Debian
packages should.
While you are free to craft whatever structure you wish for servers which need
to be authoritative for additional zones, what we suggest is that you put the
db files for any zones you are master for in /etc/bind (perhaps even in a
subdirectory structure depending on complexity), using full pathnames in the
named.conf file. Any zones you are secondary for should be configured in
named.conf with simple filenames (relative to /var/cache/bind), so the data
files will be stored in BIND's working directory (defaults to /var/cache/bind).
Zones subject to automatic updates (such as via DHCP and/or nsupdate) should be
stored in /var/lib/bind, and specified with full pathnames.
Running Chroot'ed:
-----------------
Several users have asked for Debian BIND to run in a "chroot jail". There are
various issues associated with making this the default configuration for the
package in Debian. In the meantime, reasonable instructions on how to do
this yourself are available on the web from:
http://www.tldp.org/HOWTO/Chroot-BIND-HOWTO.html
Running Non-Root:
-----------------
Recent versions of named can be invoked with options that specify a non-root
user and/or group for named. Read the named man page for more information.
Note that when running named as a user other than root, it will not be able
to find new interfaces that appear dynamically, such as during a PCMCIA card
insertion, or if you're running some flavors of IPSEC and/or IP over IP
tunnels. If you cannot live with those limitations, feel free to edit the
/etc/init.d/bind9 script to change the invocation of named.
The default is now to run as the user 'bind' (which is automatically created
in the group 'bind', if it doesn't exist), unless named.conf has been changed.
To change this, edit /etc/default/bind9
Please note that 'ndc restart' doesn't honor all the original command line
options to named, so we explicitly don't use it in the init.d script provided
with the package, and you should be careful about using it if you decide to
run named non-root.
PPP Control Script:
-----------------
Unfortunately, 'ndc reload' will not honor any command line options that were
fed to named on the initial invocation. If you can live with that, and
want to wiggle your DNS configuration when your PPP link goes up or down, the
following script fragment from Francesco Potorti` <pot@gnu.org> may be helpful
to you:
I suggest adding this as bot /etc/ppp/ip-up.d/bind and
/etc/ppp/ip-down.d/bind:
================================================================
#!/bin/sh
if [ -x /usr/sbin/ndc -a -x /usr/sbin/named ]
then
/usr/sbin/ndc reload > /dev/null
fi
================================================================
This should cause no harm in any case, and should be helpful in these
cases:
- you configure bind as a forwarder. When ppp is down, it cannot access
the network. As soon as ppp is up, it is forced by the script to try
again, and it succeeds.
- someone writes a clever script that, coupled with the `usepeerdns'
command of pppd, makes a forwarding-only bind use the right servers by
rewriting the configuration file after ppp goes up. Then the script
above makes bind reload the configuration.
Now, someone should write that clever script :-)
By the way, this is a badly wanted feature, that should help setting up
a ppp connection automatically. Currently, setting up a ppp connection
is much easier on a windows system than on linux, and there is really no
reason why it should be so, given that all the tools are there.
Apparmor Profile
----------------
If your system uses apparmor, please note that the shipped enforcing profile
works with the default installation, and changes in your configuration may
require changes to the installed apparmor profile. Please see
https://wiki.ubuntu.com/DebuggingApparmor before filing a bug against this
software.

View File

@ -0,0 +1,19 @@
$TTL 7200
@ IN SOA osiris.tp.scr. root.tp.scr. (
202306061627 ;Serial
3600 ;Refresh
60 ;Retry
86400 ;Expire
600) ;Negative Catching TTL
;
@ IN NS eno.tp.scr.
@ IN NS owt.tp.scr.
@ IN NS eerht.tp.scr.
@ IN NS ruof.tp.scr.
@ IN NS osiris.tp.scr.
eno IN A 192.168.1.1
owt IN A 192.168.1.2
eerht IN A 192.168.1.3
ruof IN A 192.168.1.4
osiris IN A 192.168.1.158

15
SCR2.2/TP22/DOC/db.tp.scr Normal file
View File

@ -0,0 +1,15 @@
$TTL 7200
@ IN SOA osiris.tp.scr. root.tp.scr. (
202306061557 ;Serial
3600 ;Refresh
60 ;Retry
86400 ;Expire
600) ;Negative Catching TTL
;
@ IN NS osiris.tp.scr.
eno IN A 192.168.1.1
owt IN A 192.168.1.2
eerht IN A 192.168.1.3
ruof IN A 192.168.1.4
osiris IN A 192.168.1.158

View File

@ -0,0 +1,15 @@
$TTL 7200
@ IN SOA osiris.tp.scr. root.tp.scr. (
202306061557 ;Serial
3600 ;Refresh
60 ;Retry
86400 ;Expire
600) ;Negative Catching TTL
;
@ IN NS osiris.tp.scr.
eno IN A 192.168.1.1
owt IN A 192.168.1.2
eerht IN A 192.168.1.3
ruof IN A 192.168.1.4
osiris IN A 192.168.1.158

View File

@ -0,0 +1,17 @@
//
// Do any local configuration here
//
// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
zone "tp.scr" {
type master ;
file "/etc/bind/db.tp.scr";
};
zone "1.168.192.in-addr.arpa" {
type master ;
file "/etc/bind/db.tp.scr.inv";
};

169
SCR2.2/TP22/dns1.imn Normal file
View File

@ -0,0 +1,169 @@
node n0 {
type lanswitch
network-config {
hostname switch1
!
}
canvas c0
iconcoords {456 96}
labelcoords {456 119}
interface-peer {e0 n1}
interface-peer {e1 n2}
interface-peer {e2 n3}
interface-peer {e3 n4}
interface-peer {e4 n5}
}
node n1 {
type host
network-config {
hostname osiris
!
interface eth0
ipv6 address fc00::10/64
mac address 42:00:aa:00:00:00
ip address 192.168.1.158/24
!
interface lo0
type lo
ip address 127.0.0.1/8
ipv6 address ::1/128
!
}
canvas c0
iconcoords {120 144}
labelcoords {120 180}
interface-peer {eth0 n0}
}
node n2 {
type pc
network-config {
hostname eno
!
interface eth0
ipv6 address fc00::20/64
mac address 42:00:aa:00:00:01
ip address 192.168.1.1/24
!
interface lo0
type lo
ip address 127.0.0.1/8
ipv6 address ::1/128
!
}
canvas c0
iconcoords {216 288}
labelcoords {216 319}
interface-peer {eth0 n0}
}
node n3 {
type pc
network-config {
hostname owt
!
interface eth0
ipv6 address fc00::21/64
mac address 42:00:aa:00:00:02
ip address 192.168.1.2/24
!
interface lo0
type lo
ip address 127.0.0.1/8
ipv6 address ::1/128
!
}
canvas c0
iconcoords {384 360}
labelcoords {384 391}
interface-peer {eth0 n0}
}
node n4 {
type pc
network-config {
hostname eerht
!
interface eth0
ipv6 address fc00::22/64
mac address 42:00:aa:00:00:03
ip address 192.168.1.3/24
!
interface lo0
type lo
ip address 127.0.0.1/8
ipv6 address ::1/128
!
}
canvas c0
iconcoords {624 360}
labelcoords {624 391}
interface-peer {eth0 n0}
}
node n5 {
type pc
network-config {
hostname ruof
!
interface eth0
ipv6 address fc00::23/64
mac address 42:00:aa:00:00:04
ip address 192.168.1.4/24
!
interface lo0
type lo
ip address 127.0.0.1/8
ipv6 address ::1/128
!
}
canvas c0
iconcoords {792 264}
labelcoords {792 295}
interface-peer {eth0 n0}
}
link l0 {
nodes {n0 n1}
bandwidth 0
}
link l1 {
nodes {n2 n0}
bandwidth 0
}
link l2 {
nodes {n3 n0}
bandwidth 0
}
link l3 {
nodes {n4 n0}
bandwidth 0
}
link l4 {
nodes {n5 n0}
bandwidth 0
}
canvas c0 {
name {Canvas0}
}
option show {
interface_names yes
ip_addresses yes
ipv6_addresses no
node_labels yes
link_labels yes
background_images no
annotations yes
hostsAutoAssign no
grid yes
iconSize normal
zoom 1.0
}

518
SCR2.2/TP23/dns2.imn Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
; This file holds the information on root name servers needed to
; initialize cache of Internet domain name servers
; (e.g. reference this file in the "cache . <file>"
; configuration file of BIND domain name servers).
;
; This file is made available by InterNIC
; under anonymous FTP as
; file /domain/named.cache
; on server FTP.INTERNIC.NET
; -OR- RS.INTERNIC.NET
;
; last update: June 08, 2023
; related version of root zone: 2023060802
;
;
; OPERATED BY WIDE
;
. 3600000 NS ROOT-SERV.
ROOT-SERV. 3600000 A 90.90.0.10
; End of file

92
SCR2.2/TP23/named.root Normal file
View File

@ -0,0 +1,92 @@
; This file holds the information on root name servers needed to
; initialize cache of Internet domain name servers
; (e.g. reference this file in the "cache . <file>"
; configuration file of BIND domain name servers).
;
; This file is made available by InterNIC
; under anonymous FTP as
; file /domain/named.cache
; on server FTP.INTERNIC.NET
; -OR- RS.INTERNIC.NET
;
; last update: June 08, 2023
; related version of root zone: 2023060802
;
; FORMERLY NS.INTERNIC.NET
;
. 3600000 NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:ba3e::2:30
;
; FORMERLY NS1.ISI.EDU
;
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 199.9.14.201
B.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:200::b
;
; FORMERLY C.PSI.NET
;
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
C.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2::c
;
; FORMERLY TERP.UMD.EDU
;
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 199.7.91.13
D.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2d::d
;
; FORMERLY NS.NASA.GOV
;
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
E.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:a8::e
;
; FORMERLY NS.ISC.ORG
;
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
F.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2f::f
;
; FORMERLY NS.NIC.DDN.MIL
;
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
G.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:12::d0d
;
; FORMERLY AOS.ARL.ARMY.MIL
;
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 198.97.190.53
H.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:1::53
;
; FORMERLY NIC.NORDU.NET
;
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
I.ROOT-SERVERS.NET. 3600000 AAAA 2001:7fe::53
;
; OPERATED BY VERISIGN, INC.
;
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30
J.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:c27::2:30
;
; OPERATED BY RIPE NCC
;
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
K.ROOT-SERVERS.NET. 3600000 AAAA 2001:7fd::1
;
; OPERATED BY ICANN
;
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 199.7.83.42
L.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:9f::42
;
; OPERATED BY WIDE
;
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
M.ROOT-SERVERS.NET. 3600000 AAAA 2001:dc3::35
; End of file

View File

@ -0,0 +1,13 @@
@ IN SOA ROOT-SERV. root. (
2007010401 ; Serial
3600 ; Refresh [1h]
600 ; Retry [10m]
86400 ; Expire [1d]
600 ) ; Negative Cache TTL [1h]
;
mos IN NS sethi.
mos IN NS kheops.
sethi.mos. IN A 80.80.0.20
kheops.mos. IN A 80.80.0.10

Binary file not shown.

View File

@ -5,7 +5,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <wait.h> #include <wait.h>
#include <fcntl.h> #include <fcntl.h>
de
int main(int argc, char **argv){ int main(int argc, char **argv){
if (argc != 3){ if (argc != 3){
@ -14,7 +13,7 @@ int main(int argc, char **argv){
} }
pid_t p; pid_t p;
int fd1, fd2; int fd1, fd2;
char buf[BUF_SIZE]; char buf1, buf2;
fd1 = open(argv[1], O_RDONLY); fd1 = open(argv[1], O_RDONLY);
fd2 = open(argv[2], O_RDONLY); fd2 = open(argv[2], O_RDONLY);
if (fd1 == -1 || fd2 == -1){ if (fd1 == -1 || fd2 == -1){
@ -27,5 +26,10 @@ int main(int argc, char **argv){
perror("Error while creating a new process"); perror("Error while creating a new process");
return EXIT_FAILURE; return EXIT_FAILURE;
case 0: case 0:
while(read // Read file a
read(fd1, &buf1, sizeof(char));
default:
//Read file b & compare both files
read(fd2, &buf2, sizeof(char));

36
SCR3.1/TP5/ex3.c Normal file
View File

@ -0,0 +1,36 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
long int fibo (long int n)
{
if (n <= 1)
return n;
long int pipe[2];
pid_t proc;
assert (pipe(pipe) >= 0);
proc = fork();
assert(proc != -1);
switch(p){
case 0:
break;
default:
/*code*/
}
}
int main(int argc, char *argv[])
{
long int n;
assert(argc > 1);
n=strtol(argv[1],NULL,0);
printf("fibo(%ld) = %ld\n",n,fibo(n));
return 0;
}

74
SCR3.1/TP6/ex3.c Normal file
View File

@ -0,0 +1,74 @@
#include <assert.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
static inline double tstamp(void)
{
struct timespec tv;
clock_gettime(CLOCK_REALTIME, &tv);
return tv.tv_sec + tv.tv_nsec * 1.0e-9;
}
typedef struct thread_arg
{
long int start;
long int limit;
long int inc;
long int S;
} thread_arg;
void *slice(void *arg)
{
thread_arg *a = (thread_arg *)arg;
long int S = 0;
for (long int i = a->start; i <= a->limit; i = i + a->inc)
{
S += i;
}
a->S = S;
return NULL;
}
int main(int argc, char *argv[])
{
long int N, M, S = 0;
thread_arg *args;
pthread_t *ths;
double t1, t2;
assert(argc >= 3);
N = strtol(argv[1], NULL, 0);
M = strtol(argv[2], NULL, 0);
t1 = tstamp();
args = (thread_arg *)calloc(M, sizeof(thread_arg));
assert(args != NULL);
ths = (pthread_t *)calloc(M, sizeof(pthread_t));
assert(ths != NULL);
for (int i = 0; i < M; i++)
{
args[i].inc = M;
args[i].limit = N;
args[i].start = i + 1;
pthread_create(ths + i, NULL, slice, (void *)(args + i));
}
for (int i = 0; i < M; i++)
{
pthread_join(ths[i], NULL);
S += args[i].S;
}
assert(S == N * (N + 1) / 2);
t2 = tstamp();
printf("S = %ld\n", S);
printf("t = %lf\n", t2 - t1);
return 0;
}

BIN
SCR3.1/TP6/max Executable file

Binary file not shown.

View File

@ -3,15 +3,18 @@
#include <assert.h> #include <assert.h>
struct stack_t { struct stack_t {
/* int size;
votre implantation int * tableau;
int index;
*/
}; };
stack_t * stack_create( int max_size) stack_t * stack_create( int max_size)
{ {
stack_t new;
new.size = max_size;
new.index = index;
return *new;
} }
@ -22,11 +25,22 @@ int stack_destroy(stack_t * s)
int stack_push(stack_t *s,int val) int stack_push(stack_t *s,int val)
{ {
if (s->index == 0){
s->tableau = malloc(s->size * sizeof(int);
}
if (s->index == s->size - 1){
return -1
}
s->tableau[value]=val;
s->value = s->value + 1;
return EXIT_SUCCESS;
} }
int stack_pop(stack_t *s,int * val) int stack_pop(stack_t *s,int * val)
{ {
if (s->index == 0){
return -1;
}
s->
} }

62
SCR3.1/devoir27/TaF27 Normal file
View File

@ -0,0 +1,62 @@
Créez un répertoire cntr_r3.05, et pour chaque exercice un sous-répertoire (Ex1,
Ex2, etc.) pour y placer vos réponses.
Les exercices sont indépendants. Vous rendrez une archive compressée à la fin de
l'épreuve sur le site :
http://www.iut-fbleau.fr/site/site/DEVOIR
# EX1
1) Ecrivez un programme gdf1.c qui implante le diagramme de processus
conforme à la sortie suivante de la commande ps :
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 30539 28785 0 80 0 - 1039 hrtime pts/0 00:00:00 a.out
1 S 1000 30542 30539 0 80 0 - 1039 hrtime pts/0 00:00:00 \_ a.out
1 S 1000 30544 30542 0 80 0 - 1039 hrtime pts/0 00:00:00 \_ a.out
1 S 1000 30546 30544 0 80 0 - 1039 hrtime pts/0 00:00:00 | \_ a.out
1 S 1000 30545 30542 0 80 0 - 1039 hrtime pts/0 00:00:00 \_ a.out
2) Expliquez (dans gdf2.txt) ce que provoque kill -TERM 30544.
3) Modifiez votre programme (gdf3.c) pour que le processus correspondant à 30546 utilise un
tube pour communiquer son PID au le processus correspondant à 30539.
# EX2
Le sous-repertoire 'src/' de votre répértoire de travail contient le source du
programme 'cachetst.c'. Ce programme peut être utilisé pour tester certaines
propriétés de la mémoire cache. Il crée une liste de structures et effectue
plusieurs passages par cette liste en faisant un test sur chaque élément.
La longueur de la liste et le nombre de passages (itérations) doivent être
donnsés sur la ligne de commande. Compilez et lancez ce programme avec par
exemple les valeurs '1000' '1000' sur la ligne de commande pour voir ce qu'il
calcule. Augmentez ces valeurs en prenant '10000' '100000' pour voir que le
temps de calcul est assez long.
Votre travail consiste à rajouter une partie de code à ce programme (appelez le
'vcachetst.c') pour qu'il affiche le nombre de tests actuellement
passés (la valeur de la variable 'z') après un ctrl + z depuis le terminal.
Mettez le source du programme 'vcachetst.c' dans le sous-repertoire 'src/'
# EX3
Écrire un programme où un processus père crée deux fils ; chaque fils attend un
couple d'entiers (x, y) du père et le renvoie dans l'ordre croissant. (combien
faut-il de tubes ?)
1. Le père prend quatre entiers a, b, c, d sur la ligne de commande,
2. il ordonne les couples (a1 , b1) et (c1, d1) grâce à ses deux fils (le père
donne le travail à **ses deux fils** avant de récupèrer le résultat)
3. Puis il ordonne les couples (a1, c1) et (b1, d1) grâce à ses deux fils, et
il obtient les couples (a2, c2) et (b2, d2).
4. Finalement, il ordonne le couple (c2 , b2) à l'aide d'un fils Il obtient le.
couple (c3, b3) .
5. Il affiche (a2 , c3 , b3 , d2).
On vieillera à fermer les descripteurs de fichiers inutilisés, à ne pas
dupliquer du code inutiliement.

View File

@ -0,0 +1,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main(void){
pid_t x, x1, x2, x3;
x1 = fork();
if (x1 == 0){
x2=fork();
if (x2 == 0)
x = fork();
x3=fork();
}
}

View File

@ -0,0 +1 @@
La commande "kill -TERM 30544" provoque l'arrêt forcé du processus 30544, à cause du signal de terminaison envoyé

View File

@ -0,0 +1,38 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#define BUF_SIZE 128
int main(void){
pid_t x, x1, x2, x3;
int p[2];
char buf;
assert(pipe(p) != -1);
x1 = fork();
if (x1 == 0){
x2=fork();
if (x2 == 0){
x = fork();
if (x == 0){
close(p[0]);
dup2(p[1], 1);
close(p[1]);
printf("%d", getpid());
}
x3=fork();
}
sleep(1);
}
if (x1 > 0){
close(p[1]);
while(read(p[0], &buf, sizeof(char)) > 0)
write(1, &buf, sizeof(char));
}
close(p[0]);
printf("\n");
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,19 @@
#include "helpers.h"
#include <signal.h>
#include <time.h>
int set_signal_handler(int signo, void (*handler)(int)) {
struct sigaction sa;
sa.sa_handler = handler; // call `handler` on signal
sigemptyset(&sa.sa_mask); // don't block other signals in handler
sa.sa_flags = SA_RESTART; // restart system calls
return sigaction(signo, &sa, NULL);
}
double tstamp(void) {
struct timespec tv;
clock_gettime(CLOCK_REALTIME, &tv);
return tv.tv_sec + tv.tv_nsec * 1.0e-9;
}

View File

@ -0,0 +1,7 @@
#ifndef _HELPERS_H
#define _HELPERS_H
int set_signal_handler(int signo, void (*handler)(int));
double tstamp(void);
#endif

View File

@ -0,0 +1,95 @@
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <x86intrin.h>
#include <signal.h>
#include "helpers.c"
#include "helpers.h"
#define PLSIZE 63
struct lst {
struct lst * next;
long int payload[PLSIZE];
} l;
struct lst * mkws(int size)
{
int i,j;
struct lst * ws0,*ws;
if (size == 0)
return NULL;
srand(time(0));
ws = calloc(1,sizeof(struct lst));
ws->next = NULL;
for (i=0;i<PLSIZE;i++)
ws->payload[i]=(rand())%2;
for (j=1;j<size;j++) {
ws0=ws;
ws = calloc(1,sizeof(struct lst));
if (ws==NULL) {
fprintf(stderr,"Can't add element...\n");
exit(1);
}
for (i=0;i<PLSIZE;i++)
ws->payload[i]=(rand())%2;
ws->next = ws0;
}
return ws;
}
long int z = 0;
void kill_prg(int){
printf("Nombre de tests effectués: %ld\n", z);
}
int main(int argc, char ** argv)
{
struct lst * ws, * ws0;
long long int start, end, dif;
long int i, x, size, it;
if (argc != 3) {
printf("Usage: %s <list size> <iterations>\n",argv[0]);
exit(1);
}
set_signal_handler(SIGTSTP, &kill_prg);
size=strtol(argv[1],NULL,0);
ws = mkws(size);
if (ws == NULL) {
printf("NIL list created...\n");
exit(1);
}
it = strtol(argv[2],NULL,0);
start = __rdtsc();
for (i = 0; i < it; i++) {
ws0 = ws;
while (ws0 != NULL) {
x = ws0->payload[3];
x++;
z++;
ws0 = ws0->next;
}
}
end = __rdtsc();
dif = end - start;
printf("Cycles/element = %lf\n", ((double) dif)/((double) size*it));
exit(0);
}

86
SCR3.1/devoir27/ex3/ex3.c Normal file
View File

@ -0,0 +1,86 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int ordre(int a, int b){
if (a < b)
return 1;
else
return 0;
}
int main(int argc, char** argv){
if (argc != 5){
printf("Usage : %s <entier1> <entier2> <entier3> <entier4>\n", argv[0]);
return EXIT_FAILURE;
}
pid_t x1, x2;
int p1[2], p2[2],tmp, a, b, c, d;
int x3 = strtod(argv[1], NULL), x4 = strtod(argv[2], NULL);
pipe(p1);
pipe(p2);
x1=fork();
x2=fork();
if (x1 > 0){
close(p1[0]);
write(p1[1],&x3, sizeof(int));
sleep(2);
write(p1[1],(int*) &x4, sizeof(int));
x3 = strtod(argv[3], NULL);
x4 = strtod(argv[4], NULL);
write(p2[1], &x3, sizeof(int));
sleep(2);
write(p2[1], &x3, sizeof(int));
close(p1[1]);
close(p2[1]);
dup(p1[0]);
read(p1[0], &a, sizeof(int));
sleep(2);
read(p1[0], &b, sizeof(int));
close(p1[0]);
dup(p2[0]);
read(p2[0], &c, sizeof(int));
sleep(2);
read(p2[0], &d, sizeof(int));
close(p2[0]);
printf("a = %d, b = %d, c = %d, d = %d\n", a, b, c, d);
}
if (x1 == 0){
close(p1[1]);
read(p1[0], &x3, sizeof(int));
sleep(2);
read(p1[0], &x4, sizeof(int));
if (!ordre(x3, x4)){
tmp = x4;
x4 = x3;
x3 = tmp;
}
printf("x3 = %d, x4 = %d", x3, x4);
close(p1[0]);
write(p1[1], &x3, sizeof(int));
sleep(2);
write(p1[1], &x4, sizeof(int));
}
if (x2 == 0){
close(p2[1]);
read(p2[0], &x3, sizeof(int));
sleep(2);
read(p2[0], &x4, sizeof(int));
ordre(x3, x4);
if (!ordre(x3, x4)){
tmp = x3;
x3 = x4;
x4 = x3;
}
dup(p2[1]);
close(p2[0]);
write(p2[1], &x3, sizeof(int));
sleep(2);
write(p2[1], &x4, sizeof(int));
}
}

View File

@ -0,0 +1,87 @@
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <x86intrin.h>
#include <signal.h>
#define PLSIZE 63
struct lst {
struct lst * next;
long int payload[PLSIZE];
} l;
struct lst * mkws(int size)
{
int i,j;
struct lst * ws0,*ws;
if (size == 0)
return NULL;
srand(time(0));
ws = calloc(1,sizeof(struct lst));
ws->next = NULL;
for (i=0;i<PLSIZE;i++)
ws->payload[i]=(rand())%2;
for (j=1;j<size;j++) {
ws0=ws;
ws = calloc(1,sizeof(struct lst));
if (ws==NULL) {
fprintf(stderr,"Can't add element...\n");
exit(1);
}
for (i=0;i<PLSIZE;i++)
ws->payload[i]=(rand())%2;
ws->next = ws0;
}
return ws;
}
int main(int argc, char ** argv)
{
struct lst * ws, * ws0;
long long int start, end, dif;
long int i, x, z = 0, size, it;
if (argc != 3) {
printf("Usage: %s <list size> <iterations>\n",argv[0]);
exit(1);
}
size=strtol(argv[1],NULL,0);
ws = mkws(size);
if (ws == NULL) {
printf("NIL list created...\n");
exit(1);
}
it = strtol(argv[2],NULL,0);
start = __rdtsc();
for (i = 0; i < it; i++) {
ws0 = ws;
while (ws0 != NULL) {
x = ws0->payload[3];
x++;
z++;
ws0 = ws0->next;
}
}
end = __rdtsc();
dif = end - start;
printf("Cycles/element = %lf\n", ((double) dif)/((double) size*it));
exit(0);
}

View File

@ -0,0 +1,19 @@
#include "helpers.h"
#include <signal.h>
#include <time.h>
int set_signal_handler(int signo, void (*handler)(int)) {
struct sigaction sa;
sa.sa_handler = handler; // call `handler` on signal
sigemptyset(&sa.sa_mask); // don't block other signals in handler
sa.sa_flags = SA_RESTART; // restart system calls
return sigaction(signo, &sa, NULL);
}
double tstamp(void) {
struct timespec tv;
clock_gettime(CLOCK_REALTIME, &tv);
return tv.tv_sec + tv.tv_nsec * 1.0e-9;
}

View File

@ -0,0 +1,7 @@
#ifndef _HELPERS_H
#define _HELPERS_H
int set_signal_handler(int signo, void (*handler)(int));
double tstamp(void);
#endif

View File

@ -0,0 +1,95 @@
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <x86intrin.h>
#include <signal.h>
#include "helpers.c"
#include "helpers.h"
#define PLSIZE 63
struct lst {
struct lst * next;
long int payload[PLSIZE];
} l;
struct lst * mkws(int size)
{
int i,j;
struct lst * ws0,*ws;
if (size == 0)
return NULL;
srand(time(0));
ws = calloc(1,sizeof(struct lst));
ws->next = NULL;
for (i=0;i<PLSIZE;i++)
ws->payload[i]=(rand())%2;
for (j=1;j<size;j++) {
ws0=ws;
ws = calloc(1,sizeof(struct lst));
if (ws==NULL) {
fprintf(stderr,"Can't add element...\n");
exit(1);
}
for (i=0;i<PLSIZE;i++)
ws->payload[i]=(rand())%2;
ws->next = ws0;
}
return ws;
}
long int z = 0;
void kill_prg(int){
printf("Nombre de tests effectués: %ld\n", z);
}
int main(int argc, char ** argv)
{
struct lst * ws, * ws0;
long long int start, end, dif;
long int i, x, size, it;
if (argc != 3) {
printf("Usage: %s <list size> <iterations>\n",argv[0]);
exit(1);
}
set_signal_handler(SIGTSTP, &kill_prg);
size=strtol(argv[1],NULL,0);
ws = mkws(size);
if (ws == NULL) {
printf("NIL list created...\n");
exit(1);
}
it = strtol(argv[2],NULL,0);
start = __rdtsc();
for (i = 0; i < it; i++) {
ws0 = ws;
while (ws0 != NULL) {
x = ws0->payload[3];
x++;
z++;
ws0 = ws0->next;
}
}
end = __rdtsc();
dif = end - start;
printf("Cycles/element = %lf\n", ((double) dif)/((double) size*it));
exit(0);
}

BIN
SCR3.1/gdf Executable file

Binary file not shown.

34
SCR3.1/gdf.c Normal file
View File

@ -0,0 +1,34 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
int main(void){
pid_t x1,x2,x3,x4;
x1=fork();
if (x1 == 0){
x2=fork();
if (x2>0) {
sleep(10);
kill(x2,SIGINT);
}
if (x2 == 0) {
x3=fork();
if (x3 == 0)
x4=fork();
if (x3 > 0){
sleep(5);
kill(x3,SIGINT);
}
}
}
if (x1 > 0)
x4=fork();
while(1) {
printf(" %d\n", getpid());
sleep(1);
}
}

BIN
arm/.small-loop.s.swp Normal file

Binary file not shown.

15
arm/add-int.s Normal file
View File

@ -0,0 +1,15 @@
.equ SYS_EXIT, 93
.data
int1 : .quad 0x15
int2 : .quad 0x2
.text
.global _start
_start: adr x3, int1
ldr x0, [x3]
adr x3, int2
ldr x1, [x3]
add x2,x0,x1
mov x0, #0
mov w8, #SYS_EXIT
svc #0

16
arm/adds-int32.s Normal file
View File

@ -0,0 +1,16 @@
.equ SYS_EXIT, 93
.data
int1 : .word 0x7fffffff
int2 : .word 0x1
.text
.global _start
_start: adr x3, int1
ldr w0, [x3]
adr x3, int2
ldr w1, [x3]
adds w2,w0,w1
mrs x4, nzcv
mov w0, #0
mov w8, #SYS_EXIT
svc #0

14
arm/barrel-experiment.s Normal file
View File

@ -0,0 +1,14 @@
.equ SYS_EXIT, 93
.data
.text
.globl _start
_start :
mov x0, #15
add x1,x0,x0,lsl #4 //x0 * 16 + x0
mov x2, #1
sub x1,xzr,x2, lsl #3 // 0 - 8
mov w8, #SYS_EXIT
svc #0

16
arm/mult-bin-loop.c Normal file
View File

@ -0,0 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
int main(){
unsigned int a = 0xa2;
unsigned int b = 0xb;
unsigned long long int res = 0;
unsigned long long int extra = (unsigned long long int) a;
while (b) {
if (b & 0x1) res += extra;
extra = extra << 1;
b = b >> 1;
}
exit(0);
}

28
arm/mult-bin-loop.s Normal file
View File

@ -0,0 +1,28 @@
.equ SYS_EXIT,93
.data
int1: .word 0xa2
int2: .word 0xb
.text
.globl _start
_start:
adr x1, int1
ldr w0, [x1]
uxtw x1, w0 // int1 is in x1
adr x2, int2
ldr w3, [x2]
uxtw x2, w3 // int2 is in x2
mov x0, #0 // result is in x0
loop:
cbz x2, exit
tbz x2, #0, next
add x0, x2, #0
next:
lsl x2, x2, #1
lsr x1, x1, #1
b loop
exit: mov x0,#0
mov w8,#SYS_EXIT
svc #0x0
.end

3
arm/notes.txt Normal file
View File

@ -0,0 +1,3 @@
cmp = subs sans sauvegarde résultat
0111 + 0001
tst =

24
arm/printHW.s Normal file
View File

@ -0,0 +1,24 @@
/*
Lines enclosed here are comments
A small program: prints "Hello World!"
*/
// From // to the end of this line is a comment: next are directives to the assembler
.equ SYS_EXIT, 93
.equ SYS_WRITE, 64
.data // tells assembler to assemble the following in the data section
msg: .asciz "Hello World!\n" //msg retains the address of the string
.text // tells assembler to assemble the following
// in the text (code) section
.globl _start // _start is there where the program starts,
// .globl makes it visible to the linker
_start:
mov x0,#1 // value 1 is placed in register x0
adr x1,msg // the address retained by label msg is placed in register x1
mov x2,#13
mov w8, #SYS_WRITE // svc must find the syscall number in w8
// and the syscall arguments in x0,x1,x2
svc #0 // invoke syscall: displays on the screen
mov x0, #0 // in x0 put the value you want to exit with
mov w8,#SYS_EXIT
svc #0
.end

18
arm/shift-experiment.s Normal file
View File

@ -0,0 +1,18 @@
.equ SYS_EXIT, 93
.data
.text
int: .quad 0x8000000000000000
.globl _start
_start :
mov x0, #1
lsl x1, x0, #3
lsr x2, x0, #1
adr x6, int
ldr x3,[x6]
lsr x4, x3, #3
asr x5, x3, #3
mov w8, #SYS_EXIT
svc #0

View File

@ -0,0 +1,16 @@
.equ SYS_EXIT, 93
.data
int: .quad 0x11223344aabbccdd
int32: .word 0x887766ee
.text
.globl _start
_start:
adr x1, int
ldr x0,[x1]
adr x1, int32
ldr w0,[x1] //Le registre x0 est vidé pour ne contenir seulement la valeur int32
sxtw x0, w0
mov x0, #0
mov w8, #SYS_EXIT
svc #0