검색결과 리스트
2012/11/19에 해당되는 글 2건
- 2012.11.19 [Greedy] 저울 (1)
- 2012.11.19 [시스템프로그래밍]03. [시스템콜]cpu_info
#include#define DEBUG 1 #define MAX_WEIGHTS 1000 void SetInputFromFile(const char* fileName, int *num_weights, int *weights); void PrintAnswerToFile(const char* fileName, int min_umw /*minimum unmeasurable weight*/); int GetMinUnmeasurableWeight(const int num_weights, int *weights); void SortWeight(int num_weights, int* weights); int main() { int num_weights; int weights[MAX_WEIGHTS]; SetInputFromFile("input.txt", &num_weights, weights); PrintAnswerToFile("output.txt", GetMinUnmeasurableWeight(num_weights, weights)); return 0; } void SetInputFromFile(const char* fileName, int *num_weights, int *weights) { int i; FILE *input = fopen(fileName, "r"); if (input == NULL) { fprintf(stderr, "Can NOT open file: \n", fileName); goto bail; } //TODO: fscanf(input, "%d", num_weights); for (i = 0; i < *num_weights; i++) { fscanf(input, "%d", &(weights[i])); } fclose(input); return; bail: if (input != NULL) fclose(input); } void PrintAnswerToFile(const char* fileName, int min_umw /*minimum unmeasurable weight*/) { FILE *output = fopen(fileName, "w"); if (output == NULL) { fprintf(stderr, "Can NOT open file: \n", fileName); goto bail; } fprintf(output, "%d\n", min_umw); fclose(output); return; bail: if (output != NULL) fclose(output); } int GetMinUnmeasurableWeight(const int num_weights, int *weights) { int pmr; // possible_measurement_range int nw; // new_weight int i; SortWeight(num_weights, weights); pmr = 0; for (i = 0; i < num_weights; i++) { nw = weights[i]; if (nw - 1 > pmr) { return pmr + 1; } pmr += nw; } return pmr + 1; } void SortWeight(int num_weights, int* weights) { int i, j, temp; for (i = 0; i < num_weights; i++) { for (j = i + 1; j < num_weights; j++) { if (weights[i] > weights[j]) { temp = weights[i]; weights[i] = weights[j]; weights[j] = temp; } } } }
arm에서 사용하는 cpu_info 구조체는 /arch/arm/include/asm/cpu.h
에 struct cpu_info_asm {...}으로 정의 되어 있다.
이 정보는 책과는 달라서 타겟의 proc/cpuinfo를 보려고 하였으나, proc파일시스템이 없는 것이다!!!!!
허걱....
그래서 FALINUX포럼에 가서 proc파일 시스템 만드는 법이 있길래 해보려고 했다..
하지만, 아직 실력이 부족해서 뭔 말인지 모르겠다.ㅠㅠㅠ
나중에 실력좀 쌓이면 타겟에 간단하게나마 proc파일 시스템을 올려 보아야 겠다.
댓글
Dans un entretien au Figaro ce vendredi, http://www.timberlandbaratas.com timberland españa, le président ivoirien reconnu par la communauté internationale se déclare une nouvelle fois prêt à accorder une amnistie à son adversaire si ce dernier accepte de céder le pouvoir pacifiquement, http://www.timberlandbaratas.com Timberland shops. Il envisage en revanche de traduire en justice pour haute trahison les membres du Conseil constitutionnel qui ont certifié la victoire de son rival, http://www.timberlandbaratas.com timberland. Alassane Ouattara accuse également de nouveau Laurent Gbagbo d'avoir "du sang sur lesmains" et énumère les "mesures coercitives" qui pourraient être prises à son encontre, http://www.timberlandbaratas.com timberland niños, du gel de ses avoirs sur l'ensemble du continent africain à l'utilisation de la "force légitime", http://www.timberlandbaratas.com Timberland Online.Related articles:
http://kingka100.tistory.com/182 Europe 1 dévoile
http://baramsog.tistory.com/107 L'ancienne secrétaire d'Etat àla Politique de la ville Fadela Amara a été nommée mercredi encon