Last change
on this file since 619 was
580,
checked in by alain, 6 years ago
|
1) Register the kernel process in the cluster manager local list.
2) Introduce a new service in idbg : display the set of busylocks taken by a given thread.
|
File size:
1.4 KB
|
Line | |
---|
1 | /////////////////////////////////////////////////////////////////////////////// |
---|
2 | // File : pgcd.c |
---|
3 | // Date : November 2017 |
---|
4 | // Author : Alain Greiner <alain.greiner@lip6.fr> |
---|
5 | /////////////////////////////////////////////////////////////////////////////// |
---|
6 | // This single thread interactive application computes the PGCD. |
---|
7 | /////////////////////////////////////////////////////////////////////////////// |
---|
8 | |
---|
9 | |
---|
10 | #include <stdio.h> |
---|
11 | #include <stdlib.h> |
---|
12 | #include <almosmkh.h> |
---|
13 | |
---|
14 | ///////////////// |
---|
15 | void main( void ) |
---|
16 | { |
---|
17 | int opx; |
---|
18 | int opy; |
---|
19 | unsigned long long cycle; |
---|
20 | unsigned int cxy; |
---|
21 | unsigned int lid; |
---|
22 | |
---|
23 | get_cycle( &cycle ); |
---|
24 | get_core( &cxy , &lid ); |
---|
25 | |
---|
26 | printf( "\n\n[PGCD] starts on core[%x,%d] / cycle %d\n", |
---|
27 | cxy , lid , (unsigned int)cycle ); |
---|
28 | |
---|
29 | while (1) |
---|
30 | { |
---|
31 | printf("\n*******************\n"); |
---|
32 | printf("operand X = "); |
---|
33 | opx = get_uint32(); |
---|
34 | printf("\n"); |
---|
35 | printf("operand Y = "); |
---|
36 | opy = get_uint32(); |
---|
37 | printf("\n"); |
---|
38 | |
---|
39 | if( (opx == 0) || (opy == 0) ) |
---|
40 | { |
---|
41 | printf("operands must be positive and larger than 0 => exit\n"); |
---|
42 | exit( 0 ); |
---|
43 | } |
---|
44 | else |
---|
45 | { |
---|
46 | while (opx != opy) |
---|
47 | { |
---|
48 | if(opx > opy) opx = opx - opy; |
---|
49 | else opy = opy - opx; |
---|
50 | } |
---|
51 | printf("pgcd = %d", opx); |
---|
52 | } |
---|
53 | } |
---|
54 | } // end pgcd |
---|
55 | |
---|
Note: See
TracBrowser
for help on using the repository browser.