source: trunk/user/pgcd/pgcd.c @ 625

Last change on this file since 625 was 625, checked in by alain, 5 years ago

Fix a bug in the vmm_remove_vseg() function: the physical pages
associated to an user DATA vseg were released to the kernel when
the target process descriptor was in the reference cluster.
This physical pages release should be done only when the page
forks counter value is zero.
All other modifications are cosmetic.

File size: 1.4 KB
RevLine 
[417]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
[436]10#include <stdio.h>
[465]11#include <stdlib.h>
[445]12#include <almosmkh.h>
[417]13
[574]14/////////////////
[475]15void main( void )
[417]16{
[436]17    int                opx;
18    int                opy;
19    unsigned long long cycle;
[580]20    unsigned int       cxy;
21    unsigned int       lid;
[417]22
[436]23    get_cycle( &cycle );
[580]24    get_core( &cxy , &lid );
[417]25
[625]26    printf( "\n\n[pgcd] starts on core[%x,%d] / cycle %d\n",
[580]27    cxy , lid , (unsigned int)cycle ); 
28
[417]29    while (1) 
30    {
31        printf("\n*******************\n");
32        printf("operand X = ");
[580]33        opx = get_uint32();
[417]34        printf("\n");
35        printf("operand Y = ");
[580]36        opy = get_uint32();
[417]37        printf("\n");
38
39        if( (opx == 0) || (opy == 0) ) 
40        {
[446]41           printf("operands must be positive and larger than 0 => exit\n");
42           exit( 0 );
[417]43        } 
44        else 
45        {
46            while (opx != opy) 
47            {
48                if(opx > opy)   opx = opx - opy;
49                else            opy = opy - opx;
50            }
[442]51            printf("pgcd      = %d", opx);
[417]52        }
53    }
54} // end pgcd
55
Note: See TracBrowser for help on using the repository browser.