Updated hello.c to print the program's PID. Add getPID syscall.
This commit is contained in:
parent
02e0bcd70e
commit
ca131c71e8
@ -28,6 +28,10 @@ uint32_t filesize(char* filename) {
|
|||||||
asm volatile ("mov $6, %%eax; mov %0, %%esi; int $0x7f" : : "m" (filename) : "esi");
|
asm volatile ("mov $6, %%eax; mov %0, %%esi; int $0x7f" : : "m" (filename) : "esi");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t getPID() {
|
||||||
|
asm volatile ("mov $8, %%eax; int $0x7f" : : :);
|
||||||
|
}
|
||||||
|
|
||||||
int int_to_decimal(unsigned int number, char* string_buffer) {
|
int int_to_decimal(unsigned int number, char* string_buffer) {
|
||||||
for (int i=0; i<11; i++)
|
for (int i=0; i<11; i++)
|
||||||
string_buffer[i] = 0;
|
string_buffer[i] = 0;
|
||||||
|
@ -11,6 +11,8 @@ void* localalloc(uint32_t size);
|
|||||||
void localdelete(void* ptr);
|
void localdelete(void* ptr);
|
||||||
uint32_t filesize(char* filename);
|
uint32_t filesize(char* filename);
|
||||||
|
|
||||||
|
uint32_t getPID();
|
||||||
|
|
||||||
int int_to_decimal(unsigned int number, char* string_buffer);
|
int int_to_decimal(unsigned int number, char* string_buffer);
|
||||||
int int_to_hex(unsigned int number, char* string_buffer);
|
int int_to_hex(unsigned int number, char* string_buffer);
|
||||||
|
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
uint32_t counter = 0;
|
||||||
|
uint32_t PID = getPID();
|
||||||
|
char intbuffer[32];
|
||||||
|
uint32_t index = int_to_decimal(PID, intbuffer);
|
||||||
while (1) {
|
while (1) {
|
||||||
// print("Hello");
|
counter++;
|
||||||
|
if (counter == 312500) {
|
||||||
|
print(intbuffer+index);
|
||||||
|
print(" ");
|
||||||
|
counter = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user