summaryrefslogtreecommitdiff
path: root/cat.c
diff options
context:
space:
mode:
authorrtm <rtm>2006-08-08 19:58:06 +0000
committerrtm <rtm>2006-08-08 19:58:06 +0000
commit0e84a0ec6e7893dad13dff9a958c5bc987b79c82 (patch)
tree5739d0a2af8277db7a47c74e52975d9e9d81cef7 /cat.c
parente8d11c2e846ad15b32caacc8a919722b76d00f79 (diff)
downloadxv6-labs-0e84a0ec6e7893dad13dff9a958c5bc987b79c82.tar.gz
xv6-labs-0e84a0ec6e7893dad13dff9a958c5bc987b79c82.tar.bz2
xv6-labs-0e84a0ec6e7893dad13dff9a958c5bc987b79c82.zip
fix race in holding() check in acquire()
give cpu1 a TSS and gdt for when it enters scheduler() and a pseudo proc[] entry for each cpu cpu0 waits for each other cpu to start up read() for files
Diffstat (limited to 'cat.c')
-rw-r--r--cat.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/cat.c b/cat.c
new file mode 100644
index 0000000..8154ae2
--- /dev/null
+++ b/cat.c
@@ -0,0 +1,35 @@
+#include "user.h"
+
+char buf[513];
+
+int
+main(int argc, char *argv[])
+{
+ int fd, i, cc;
+
+ if(argc < 2){
+ puts("Usage: cat files...\n");
+ exit();
+ }
+
+ for(i = 1; i < argc; i++){
+ fd = open(argv[i], 0);
+ if(fd < 0){
+ puts("cat: cannot open ");
+ puts(argv[i]);
+ puts("\n");
+ exit();
+ }
+ while((cc = read(fd, buf, sizeof(buf) - 1)) > 0){
+ buf[cc] = '\0';
+ puts(buf);
+ }
+ if(cc < 0){
+ puts("cat: read error\n");
+ exit();
+ }
+ close(fd);
+ }
+
+ exit();
+}