Wed Jun 3 15:17:46 2020
EVENTS
 FREE
SOFTWARE
INSTITUTE

POLITICS
JOBS
MEMBERS'
CORNER

MAILING
LIST

NYLXS Mailing Lists and Archives
NYLXS Members have a lot to say and share but we don't keep many secrets. Join the Hangout Mailing List and say your peice.

DATE 2015-03-01

LEARN

2020-06-03 | 2020-05-03 | 2020-04-03 | 2020-03-03 | 2020-02-03 | 2020-01-03 | 2019-12-03 | 2019-11-03 | 2019-10-03 | 2019-09-03 | 2019-08-03 | 2019-07-03 | 2019-06-03 | 2019-05-03 | 2019-04-03 | 2019-03-03 | 2019-02-03 | 2019-01-03 | 2018-12-03 | 2018-11-03 | 2018-10-03 | 2018-09-03 | 2018-08-03 | 2018-07-03 | 2018-06-03 | 2018-05-03 | 2018-04-03 | 2018-03-03 | 2018-02-03 | 2018-01-03 | 2017-12-03 | 2017-11-03 | 2017-10-03 | 2017-09-03 | 2017-08-03 | 2017-07-03 | 2017-06-03 | 2017-05-03 | 2017-04-03 | 2017-03-03 | 2017-02-03 | 2017-01-03 | 2016-12-03 | 2016-11-03 | 2016-10-03 | 2016-09-03 | 2016-08-03 | 2016-07-03 | 2016-06-03 | 2016-05-03 | 2016-04-03 | 2016-03-03 | 2016-02-03 | 2016-01-03 | 2015-12-03 | 2015-11-03 | 2015-10-03 | 2015-09-03 | 2015-08-03 | 2015-07-03 | 2015-06-03 | 2015-05-03 | 2015-04-03 | 2015-03-03 | 2015-02-03 | 2015-01-03 | 2014-12-03 | 2014-11-03 | 2014-10-03

Key: id Value: 543032

Key: archive_learn Value: 2015-03-01

MESSAGE
DATE 2015-03-08
FROM Ruben Safir
SUBJECT Subject: [LIU Comp Sci] Operating systems HW
From owner-learn-outgoing-at-mrbrklyn.com Sun Mar 8 20:23:17 2015
Return-Path:
X-Original-To: archive-at-mrbrklyn.com
Delivered-To: archive-at-mrbrklyn.com
Received: by mrbrklyn.com (Postfix)
id BE5A1161304; Sun, 8 Mar 2015 20:23:17 -0400 (EDT)
Delivered-To: learn-outgoing-at-mrbrklyn.com
Received: by mrbrklyn.com (Postfix, from userid 28)
id AC394161307; Sun, 8 Mar 2015 20:23:17 -0400 (EDT)
Delivered-To: learn-at-nylxs.com
Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89])
by mrbrklyn.com (Postfix) with ESMTP id ED4F4161304
for ; Sun, 8 Mar 2015 20:22:52 -0400 (EDT)
Received: from [10.0.0.19] (unknown [96.57.23.82])
by mailbackend.panix.com (Postfix) with ESMTPSA id 1210E11D58;
Sun, 8 Mar 2015 20:22:51 -0400 (EDT)
Message-ID: <54FCE7DB.3000700-at-panix.com>
Date: Sun, 08 Mar 2015 20:22:51 -0400
From: Ruben Safir
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0
MIME-Version: 1.0
To: mohammed Ghriga
Subject: [LIU Comp Sci] Operating systems HW
Content-Type: multipart/mixed;
boundary="------------030300070906050409080202"
Sender: owner-learn-at-mrbrklyn.com
Precedence: bulk
Reply-To: learn-at-mrbrklyn.com

This is a multi-part message in MIME format.
--------------030300070906050409080202
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

I lost track of what the home work was, but before I moved forward
answering quiz questions, I wanted to tackle some of the coding
assignments in Chapter 2, because I thought I could learn a lot more
from them. So I did read Cpt 2 and 3, but I wanted to finish this which
was good because I completely forgot a number of things about fstat,
fopen and the use of strace, I had never done that before actually
although I am familiar and used extensively nm. I made a lot of
blunders on the way to finishing this, but others might benefit from
this as well. I'm going on to doing the kernel programming tonight, I
hope and tackle chapter 3 'quiz' questions at school in the AM before class.

Ruben

#include
#include
#include
#include
#include

char buf[500] = {0};
char buf2[500] = {0};
char * buf3;
int fd, ret;
size_t len;
const char * PASSWD = "/etc/passwd";
off_t tmpsize;

struct stat filetmp;

FILE * INPUT;
FILE * OUTPUT;
int main( int argc, char * argv[])
{
puts ("Enter a file to copy\n");
if ( ! fgets( buf, 500, stdin) )
return EXIT_FAILURE;
len = strlen(buf);
buf[len-1] = 0;


puts ("Enter the file to copy to\n");
if ( ! fgets( buf2, 500, stdin) )
return EXIT_FAILURE;
len = strlen(buf2);
buf2[len-1] = 0;

if( access( buf, F_OK|R_OK ) == 0 ) {
INPUT = fopen( buf, "r");
if (INPUT == NULL){
printf("Can't Open %s\n", buf);
exit(EXIT_FAILURE);
}
}else{
perror("access INPUT file stat");
exit (EXIT_FAILURE);
}
//File Opened for reading
fd = fileno(INPUT);
if (fstat(fd, &filetmp ) == -1){
perror("stat on reading file:");
exit(EXIT_FAILURE);
}
//FILE IS STATTED
tmpsize = filetmp.st_size;
if( (buf3 = (char *) malloc( sizeof(int) * tmpsize)) == NULL)
exit (EXIT_FAILURE);
ret = fread(buf3, tmpsize, 1, INPUT);
if( ret != 1){
fprintf(stderr, "Read not complete: Req ==> %d Rec ==> %zu \n",
ret, tmpsize);
exit(EXIT_FAILURE);
}

OUTPUT = fopen(buf2, "w");
if(OUTPUT == NULL){
printf("Can't Open %s\n ", buf2);
exit(EXIT_FAILURE);
}
//File Open for Writing
ret = fwrite(buf3, tmpsize, 1, OUTPUT);
if(ret != 1){
perror("WRITE");
fprintf(stderr, "WRITE not complete: Req ==> %d Rec ==> %zu\n",
ret, tmpsize);
exit(EXIT_FAILURE);
}
free(buf3);
fclose(INPUT);
fclose(OUTPUT);
return 1;
}

execve("./a.out", ["./a.out"], [/* 55 vars */]) = 0
brk(0) = 0x68b000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f71c0fdb000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or
directory)
open("/home/ruben/GNUstep/Library/Libraries/tls/x86_64/libc.so.6",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/ruben/GNUstep/Library/Libraries/tls/x86_64", 0x7fffd1634d10)
= -1 ENOENT (No such file or directory)
open("/home/ruben/GNUstep/Library/Libraries/tls/libc.so.6",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/ruben/GNUstep/Library/Libraries/tls", 0x7fffd1634d10) = -1
ENOENT (No such file or directory)
open("/home/ruben/GNUstep/Library/Libraries/x86_64/libc.so.6",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/ruben/GNUstep/Library/Libraries/x86_64", 0x7fffd1634d10) =
-1 ENOENT (No such file or directory)
open("/home/ruben/GNUstep/Library/Libraries/libc.so.6",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/home/ruben/GNUstep/Library/Libraries", 0x7fffd1634d10) = -1
ENOENT (No such file or directory)
open("/root/GNUstep/Library/Libraries/tls/x86_64/libc.so.6",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/root/GNUstep/Library/Libraries/tls/x86_64", 0x7fffd1634d10) = -1
ENOENT (No such file or directory)
open("/root/GNUstep/Library/Libraries/tls/libc.so.6",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/root/GNUstep/Library/Libraries/tls", 0x7fffd1634d10) = -1 ENOENT
(No such file or directory)
open("/root/GNUstep/Library/Libraries/x86_64/libc.so.6",
O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/root/GNUstep/Library/Libraries/x86_64", 0x7fffd1634d10) = -1
ENOENT (No such file or directory)
open("/root/GNUstep/Library/Libraries/libc.so.6", O_RDONLY|O_CLOEXEC) =
-1 ENOENT (No such file or directory)
stat("/root/GNUstep/Library/Libraries", 0x7fffd1634d10) = -1 ENOENT (No
such file or directory)
open("/usr/lib/tls/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT
(No such file or directory)
stat("/usr/lib/tls/x86_64", 0x7fffd1634d10) = -1 ENOENT (No such file or
directory)
open("/usr/lib/tls/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such
file or directory)
stat("/usr/lib/tls", 0x7fffd1634d10) = -1 ENOENT (No such file or
directory)
open("/usr/lib/x86_64/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No
such file or directory)
stat("/usr/lib/x86_64", 0x7fffd1634d10) = -1 ENOENT (No such file or
directory)
open("/usr/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3,
"\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\1\2\0\0\0\0\0"..., 832)
= 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1984416, ...}) = 0
mmap(NULL, 3813200, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3,
0) = 0x7f71c0a18000
mprotect(0x7f71c0bb1000, 2097152, PROT_NONE) = 0
mmap(0x7f71c0db1000, 24576, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x199000) = 0x7f71c0db1000
mmap(0x7f71c0db7000, 16208, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f71c0db7000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f71c0fda000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f71c0fd9000
arch_prctl(ARCH_SET_FS, 0x7f71c0fda700) = 0
mprotect(0x7f71c0db1000, 16384, PROT_READ) = 0
mprotect(0x7f71c0fdc000, 4096, PROT_READ) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 6), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f71c0fd8000
write(1, "Enter a file to copy\n", 21) = 21
write(1, "\n", 1) = 1
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 6), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f71c0fd7000
read(0, "/etc/passwd\n", 1024) = 12
write(1, "Enter the file to copy to\n", 26) = 26
write(1, "\n", 1) = 1
read(0, "/home/ruben/ssadsa.tmp\n", 1024) = 23
access("/etc/passwd", R_OK) = 0
brk(0) = 0x68b000
brk(0x6ac000) = 0x6ac000
open("/etc/passwd", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1637, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=1637, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f71c0fd6000
read(3, "root:x:0:0:root:/root:/bin/bash\n"..., 4096) = 1637
open("/home/ruben/ssadsa.tmp", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x7f71c0fd5000
close(3) = 0
munmap(0x7f71c0fd6000, 4096) = 0
write(5, "root:x:0:0:root:/root:/bin/bash\n"..., 1637) = 1637
close(5) = 0
munmap(0x7f71c0fd5000, 4096) = 0
exit_group(1) = ?
+++ exited with 1 +++


--------------030300070906050409080202
Content-Type: text/plain; charset=UTF-8;
name="output"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="output"

ZXhlY3ZlKCIuL2Eub3V0IiwgWyIuL2Eub3V0Il0sIFsvKiA1NSB2YXJzICovXSkgPSAwCmJy
aygwKSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA9IDB4NjhiMDAwCm1tYXAo
TlVMTCwgNDA5NiwgUFJPVF9SRUFEfFBST1RfV1JJVEUsIE1BUF9QUklWQVRFfE1BUF9BTk9O
WU1PVVMsIC0xLCAwKSA9IDB4N2Y3MWMwZmRiMDAwCmFjY2VzcygiL2V0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M3KSA9IDE2MzcKY2xv
c2UoNSkgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gMAptdW5tYXAoMHg3Zjcx
YzBmZDUwMDAsIDQwOTYpICAgICAgICAgICAgPSAwCmV4aXRfZ3JvdXAoMSkgICAgICAgICAg
ICAgICAgICAgICAgICAgICA9ID8KKysrIGV4aXRlZCB3aXRoIDEgKysrCg==
--------------030300070906050409080202
Content-Type: text/x-csrc;
name="mycp.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="mycp.c"

#include
#include
#include
#include
#include

char buf[500] = {0};
char buf2[500] = {0};
char * buf3;
int fd, ret;
size_t len;
const char * PASSWD = "/etc/passwd";
off_t tmpsize;

struct stat filetmp;

FILE * INPUT;
FILE * OUTPUT;
int main( int argc, char * argv[])
{
puts ("Enter a file to copy\n");
if ( ! fgets( buf, 500, stdin) )
return EXIT_FAILURE;
len = strlen(buf);
buf[len-1] = 0;


puts ("Enter the file to copy to\n");
if ( ! fgets( buf2, 500, stdin) )
return EXIT_FAILURE;
len = strlen(buf2);
buf2[len-1] = 0;

if( access( buf, F_OK|R_OK ) == 0 ) {
INPUT = fopen( buf, "r");
if (INPUT == NULL){
printf("Can't Open %s\n", buf);
exit(EXIT_FAILURE);
}
}else{
perror("access INPUT file stat");
exit (EXIT_FAILURE);
}
//File Opened for reading
fd = fileno(INPUT);
if (fstat(fd, &filetmp ) == -1){
perror("stat on reading file:");
exit(EXIT_FAILURE);
}
//FILE IS STATTED
tmpsize = filetmp.st_size;
if( (buf3 = (char *) malloc( sizeof(int) * tmpsize)) == NULL)
exit (EXIT_FAILURE);
ret = fread(buf3, tmpsize, 1, INPUT);
if( ret != 1){
fprintf(stderr, "Read not complete: Req ==> %d Rec ==> %zu \n", ret, tmpsize);
exit(EXIT_FAILURE);
}

OUTPUT = fopen(buf2, "w");
if(OUTPUT == NULL){
printf("Can't Open %s\n ", buf2);
exit(EXIT_FAILURE);
}
//File Open for Writing
ret = fwrite(buf3, tmpsize, 1, OUTPUT);
if(ret != 1){
perror("WRITE");
fprintf(stderr, "WRITE not complete: Req ==> %d Rec ==> %zu\n", ret, tmpsize);
exit(EXIT_FAILURE);
}
free(buf3);
fclose(INPUT);
fclose(OUTPUT);
return 1;
}


--------------030300070906050409080202--

  1. 2015-03-01 Ruben <ruben.safir-at-my.liu.edu> Subject: [LIU Comp Sci] Fwd: Re: Linked List Test Question
  2. 2015-03-02 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] [ruben-at-mrbrklyn.com: fork problem]
  3. 2015-03-03 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Re: fork problem
  4. 2015-03-04 Maneesh Kongara <maneeshkongara-at-gmail.com> Re: [LIU Comp Sci] Mid term in Allorithms
  5. 2015-03-04 Ruben Safir <mrbrklyn-at-panix.com> Re: [LIU Comp Sci] Mid term in Allorithms
  6. 2015-03-04 Maneesh Kongara <maneeshkongara-at-gmail.com> Re: [LIU Comp Sci] Mid term in Allorithms
  7. 2015-03-04 Ruben Safir <mrbrklyn-at-panix.com> Re: [LIU Comp Sci] Mid term in Allorithms
  8. 2015-03-04 Ruben Safir <ruben.safir-at-my.liu.edu> Re: [LIU Comp Sci] Mid term in Allorithms
  9. 2015-03-04 Maneesh Kongara <maneeshkongara-at-gmail.com> Re: [LIU Comp Sci] Mid term in Allorithms
  10. 2015-03-04 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Kanpsack problemi
  11. 2015-03-04 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Mid term in Allorithms
  12. 2015-03-05 Kamran <kamran.mirzayev-at-my.liu.edu> Re: [LIU Comp Sci] Canonical's 2015 OpenStack Roadshow
  13. 2015-03-05 mrbrklyn-at-panix.com Subject: [LIU Comp Sci] Canonical's 2015 OpenStack Roadshow
  14. 2015-03-05 Ruben <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Forks - Operating systems class
  15. 2015-03-06 Ruben <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] KDE Mentoring -
  16. 2015-03-06 Ruben <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] networking class
  17. 2015-03-07 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Operating Systems class submition
  18. 2015-03-08 From: "keisha.sylvester" <keisha.sylvester-at-my.liu.edu> RE: [LIU Comp Sci] Operating Systems Supplement Text
  19. 2015-03-08 Ruben <ruben.safir-at-my.liu.edu> Re: [LIU Comp Sci] Operating Systems Supplement Text
  20. 2015-03-08 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Operating systems HW
  21. 2015-03-08 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Operating Systems Supplement Text
  22. 2015-03-08 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Re: Operating systems HW
  23. 2015-03-11 Ruben Safir <mrbrklyn-at-panix.com> Re: [LIU Comp Sci] Operating Systems class submition
  24. 2015-03-11 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] February Journal almost completed
  25. 2015-03-16 mrbrklyn-at-panix.com Subject: [LIU Comp Sci] Operating Systems Chapter 3 HW complete
  26. 2015-03-16 mrbrklyn-at-panix.com Subject: [LIU Comp Sci] [ruben-at-mrbrklyn.com: os hw]
  27. 2015-03-17 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Fwd: NYC local: UNIGROUP 19-MAR-2015 (Thu): Penguin Computing presents
  28. 2015-03-19 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] LIU Center for Entrepreneurship + Innovation
  29. 2015-03-20 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Optimum
  30. 2015-03-20 mrbrklyn-at-panix.com Subject: [LIU Comp Sci] [jkeen-at-verizon.net: 2nd New York City Perl Hackathon: hold the
  31. 2015-03-22 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Re: Kernel thread scheduling
  32. 2015-03-22 mrbrklyn-at-panix.com Subject: [LIU Comp Sci] [jkeen-at-verizon.net: New York City Perl Hackathon 2015: Registration
  33. 2015-03-22 mrbrklyn-at-panix.com Subject: [LIU Comp Sci] [vinc94-at-gmail.com: Re: Kernel thread scheduling]
  34. 2015-03-22 mrbrklyn-at-panix.com Subject: [LIU Comp Sci] [xerofoify-at-gmail.com: Re: Kernel thread scheduling]
  35. 2015-03-23 Keisha Sylvester <keisha.sylvester-at-my.liu.edu> Re: [LIU Comp Sci] Meeting Announcement II
  36. 2015-03-23 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Meeting Announcement II
  37. 2015-03-23 mrbrklyn-at-panix.com Subject: [LIU Comp Sci] [gabor-at-szabgab.com: [Perlweekly] #191 - Hackathon after Hackathon]
  38. 2015-03-24 Maneesh Kongara <maneeshkongara-at-gmail.com> Re: [LIU Comp Sci] GNU/Linux 1
  39. 2015-03-24 Maneesh Kongara <maneeshkongara-at-gmail.com> Re: [LIU Comp Sci] GNU/Linux 1
  40. 2015-03-24 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] GNU/Linux 1
  41. 2015-03-25 Ruben Safir <mrbrklyn-at-panix.com> Re: [LIU Comp Sci] GNU/Linux 1
  42. 2015-03-25 Ruben <ruben.safir-at-my.liu.edu> Re: [LIU Comp Sci] GNU/Linux 1
  43. 2015-03-25 Ruben Safir <mrbrklyn-at-panix.com> Re: [LIU Comp Sci] GNU/Linux 1
  44. 2015-03-25 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] decent threading outline that fills in where our notes let off
  45. 2015-03-25 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] I love this HW problem
  46. 2015-03-25 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Java Crimes
  47. 2015-03-25 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] jobs jobs
  48. 2015-03-25 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Threaded Programming example
  49. 2015-03-25 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Threads and Speed
  50. 2015-03-26 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Cpt 4 HW from pr 13-18
  51. 2015-03-26 Ruben <ruben.safir-at-my.liu.edu> Subject: [LIU Comp Sci] Fwd: [NYLXS - HANGOUT] GNU/Linux 1
  52. 2015-03-26 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Kernel Learning Resource - #1
  53. 2015-03-27 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] AVl Trees
  54. 2015-03-27 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Re: Cpt 4 HW Programming Project 4-20 (and 3-20)
  55. 2015-03-28 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Jobs
  56. 2015-03-28 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] JOUNAL MEETING AT 10AM TOMORROW
  57. 2015-03-29 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] Fwd: usage of dma_common_mmap
  58. 2015-03-30 Ruben Safir <mrbrklyn-at-panix.com> Subject: [LIU Comp Sci] HW 4.18 Problem

NYLXS are Do'ers and the first step of Doing is Joining! Join NYLXS and make a difference in your community today!