Jump to content

Tuero

Member
  • Posts

    54
  • Joined

  • Last visited

Awards

This user doesn't have any awards

Profile Information

  • Gender
    Not Telling
  1. I use all 3 major OS's on a daily basis (Windows desktop, MacOS, Ubuntu workstation/desktop), and I work in the ML/Deep learning space, so my answers are a bit biased towards that. My end goal is to have a separate personal Ubuntu box for dev work which I ssh into while my main box would be Windows. I put a lot of money into my worksation so I can only afford one box at the moment, so Ubuntu is the main OS with Windows running in a QEMU VM Historically, all the major ML/DL frameworks have been built with Linux in mind. Its a bit easier now, but in the past non-linux systems would either be completely incompatible, or you would suffer major performance hits trying to get these to run on Windows For these frameworks, often you would need separate versions of CUDA, python, etc. and Docker was a real PITA on Windows to handle this A lot of the standard tools you would need/want as a programmer (make, shh, your favourite C compiler) either already comes or takes 5 seconds to setup in Linux. Its almost faster to create a new partition and install Linux on your Windows machine than it is to get these things setup in Windows Mind you, a lot of this has changed for the better and is getting easier on Windows, but I don't think it will ever catch up to Linux for this area. I don't particularly like Linux as a main OS, I would much rather use Windows as everything just feels nicer and some things are a real pain to setup or get support for on Linux. That being said, I am willing to sacrifice those nice to have if it means my workflow is much easier to deal with. Once I have my monitors filled with terminal/sublimetext, I am happy
  2. Tuero

    Processes in C

    I have a bit more code than that but I just wanted to get across the main point of the program so I just cut stuff out and thats why I may be missing semi-colons, etc. We are given "templates" by our prof as too function prototypes, definitions, etc. so I am just following them. We are using ssh to do our work on the school server using gcc, so which ever version they are using, I am not sure (the compiler gives no warnings for the implicit declarations). I have tried running the cleaned up code on OSX as a test and I do get the same output which you got (the lower PID starts before the higher PID, but the higher PID finishes before the lower PID). I am just more concerned on whether I am doing something wrong, or if this is just one of the issues like race conditions while using multi-threading.
  3. For an assignment, we are required to make two child processes. I have the code working fine, but I have a question with regards to the order in which the processes finish. Based on the code below, I would think that the first child process should finished before the second, but every time I run the code, the second child process finished before the first. The output I get is as follows (the PID is always different for each run through, but the PID which is larger always finished before the PID one below it, which doesn't make sense. before: mypid is 10258 waiting for 10259 and 10260 child 10260 here, will sleep for 2 seconds child 10259 here, will sleep for 2 seconds child done. about to exit child done. about to exit Wait returned: 10260 Wait returned: 10259 #include <stdio.h> #include <stdlib.h> #define DELAY 2 main(){ int newpid1, newpid2; void child_code(), parent_code(); printf("before: mypid is %d\n", getpid()); newpid1 = fork(); if ( newpid1 == 0 ){ child_code(DELAY); } else{ // create second child newpid2 = fork() if ( newpid2 == 0 ){ child_code(DELAY); } else{ parent_code(newpid1, newpid2); } } return 0; } void child_code(int delay){ printf( "child %d here, will sleep for %d seconds\n", getpid(), delay ); sleep( delay ); printf( "child done. about to exit\n" ); exit(17); } void parent_code(int child1, int child2){ int wait_rv1, wait_rv2; printf("waiting for %d and %d \n", child1, child2); wait_rv1 = wait(NULL); wait_rv2 = wait(NULL); printf("Wait returned: %d\n", wait_rv1); printf("Wait returned: %d\n", wait_rv2); }
  4. I think everyone should has an SSD in their system as it gives reliable data integrity with blazing fast speeds. Why wait a minute for your PC to boot when you can cut the time down by multiple factors with an SSD!!!
  5. We had to do this for an assignment. I am not sure how familiar you are with data structures, but we had to use binary search trees to store the morse code and english equivalent. The contents of the search tree are ordered based on their english lettering order, so you simply search the tree until you match your english letter, then you return the morse code equivalent which is stored at the same node
  6. I am taking CS in school, and it is getting to the point where we are learning a good number of languages (we have currently been 'taught' python, visual basic, java, c, assembly, and now starting c++). Some of the languages share quite a bit of syntax (java/c/c++) and the only way to get better is to practice practice practice, what do you find helps you to keep your 'tools sharp' with all the languages you may know. Like if you are primarily using one or two languages day to day for work or whatever, do you try implementing the same thing in a different language? It just seems that we are being thrown a lot of different stuff and by the time you are learning your third or fourth language you start to forget some stuff you may have done in python. Currently, I find myself going back to the languages like python and java and implementing stuff we learned from C like data structures, etc. It just seems like there is so much information out there for each language its hard to keep it all in your head!
  7. Thanks everyone for you're suggestions, I will definitely look into those! I talked to my prof about it, and it turns out that we are able to assume that a bad input will only be a single character instead of something more complicated like "12a", which allows us to just check the value of scanf as an int and as long as it is equal to the number of floats I am trying to get, then that is fine.
  8. I have to write a program which solves for the roots of a quadratic equation (ax^2 + bx + c). I have all the math down and the program works, its just handling bad input. The user has to input 3 numbers, formatted as such: "a,b,c" (ex. 1,2,1). The problem arrises when I enter in something as such ("a,b,c" or "a,b" i.e. non-number characters). From what I have tested, if I enter in a good input first (1,2,1) and then I try a bad input (a, b ), the values from before are kept. I need some way to test whether there is a valid input or not. I have posted my code below. From what I have read, scanf is very bad for when you cannot control how the input if formatted, as an input for an integer such as "123abc" would count as a good input, since the "123" is read fine but scanf just 'ignores' the abc. For the purpose of this assignment, we need to use scanf My code is posted below (forum won't let me post my code as its blocking me so I made a pastebin link): http://pastebin.com/dBbqHN2S
  9. Have tried that. Still no change Thats my solution at the moment. Every time it happens, I have to close all my windows and re open chrome to fix it. Its an inconvenience to have to do it every time my computer goes to sleep
  10. Is anyone else having this issue? When I put my computer to sleep and wake up after a while, the text in my last used active chrome window becomes chopped off, and the clickable links are off centered from their position on the page. This has only happened in chrome on windows 10, none of my other applications do this. I am on the latest version of chrome, and I have tried to show you what I mean with pictures attached below. Thanks!!!
  11. Brilliant, that works perfectly. Thanks again!!
  12. I am working on an assignment for a course that I am taking, so I cannot change the underlying methodology of how the program will work. Anyways, I have a Sorts class, which contains multiple methods which are different types of sorting algorithms. Each method is preceded by the @staticmethod decorator. At the beginning of the class is a global variable, which each of the methods updates. The outline of the code is as follows: In another python module, I have a function which will take in a function name as a parameter (that being one of the sort algorithms name), and will sort an unsorted array using that method. Then, I need to be able to grab the swaps value. Since decorators are used, we run a sorting algorithm by the following I am wondering how I can then access the swaps value? Normally, you would create an object, and then access the value by Object.Attribute = whatever. However, since we are using the @staticmethod decorator, we do not need to explicitly create an object. So how can I reference the attribute when we do not have an explicit object to refer to? Thanks!
  13. @ctrlaltChris thanks for that book dump, there are some gems in there!
  14. The important thing is to understand how to program and get around problems. There are often times where i need to do some macros in VBA Excel where I know what how the program structure needs to be line by line, I just can't remember the syntax for a method. An easy Google search solves this problem! Also, don't get too worked up on memorizing things. If you work with the syntax enough it will get burned into your memory through repeated exposure and you will find that you just type it out without even thinking about. Everything is hard at first, just keep at it and practice!!
  15. I haven't take an indepth look at objective-C but from what I have read, the language was pretty clunky. So far I find swift pretty intuitive and easy to understand
×