system-calls

Print 64 bit number stored in EDX:EAX to standard out

你说的曾经没有我的故事 提交于 2019-12-11 12:09:25
问题 I have large 64 bit number stored in EDX:EAX as 21C3677C:82B40000 respectively. I'm trying to print the number out to the console as a decimal 2432902008176640000 Is there a system call that will allow me to accomplish this? 回答1: Someone has to have mercy on this guy and his classmates. If "just call printf" isn't cheating, using this shouldn't be cheating either. I stole this from one of the first asm programs I ever encountered. It used a DOS interrupt to find the disk size and printed dx

system vs call vs popen in Python

笑着哭i 提交于 2019-12-11 10:11:02
问题 cmd = 'touch -d '+date_in+' '+images_dir+'/'+photo_name os.system(cmd) Doesn't work subprocess.call(['touch','-d','{}'.format(date_in),'{}'.format(images_dir+'/'+photo_name)]) Doesn't work subprocess.Popen(['touch','-d','{}'.format(date_in),'{}'.format(images_dir+'/'+photo_name)]) Works! Why? What am I missing in first two cases? pi@raspberrypi:~ $ python --version Python 2.7.13 Actual code snippet: try: response = urllib2.urlopen(url) if(response.getcode() == 200): photo_file = response.read

Running AppleScripts through the ScriptMonitor.app Utility

我是研究僧i 提交于 2019-12-11 09:52:20
问题 When AppleScripts are run through the system-wide Script Menu, their progress is displayed in the menu bar using the ScriptMonitor applet (located in /System/Library/CoreServices/ScriptMonitor.app , introduced in OS X Yosemite). This allows you to stay aware of running scripts, monitor progress, and easily stop running scripts. Is it possible to run AppleScripts through the ScriptMonitor from outside the Script Menu, for example from Terminal or from system calls from other applications? I

Using Linux C select system call to monitor files

不羁的心 提交于 2019-12-11 09:28:16
问题 I creates two files in the execution folder of the following code, one named test and the other is test2 . I run the following code in one terminal which "monitors" those two files for changes, but the select call returns all the time even when the file is not touched. #include <fcntl.h> /* fcntl */ #include <sys/select.h> /* select */ #include <stdio.h> /* NULL */ int main() { fd_set readfds, writefds; int max_fd; int fd_1 = open("test", O_RDWR | O_NONBLOCK); int fd_2 = open("test2", O_RDWR

differ in output of df and statfs

穿精又带淫゛_ 提交于 2019-12-11 08:51:48
问题 why is the output of df command and statfs() system call values are different: program to call statfs: #include <stdio.h> #include <errno.h> #include <sys/types.h> #include <sys/vfs.h> #include <string.h> #include <stdlib.h> int main() { struct statfs vfs; if (statfs("/", & vfs) != 0) { fprintf(stderr, "%s: statfs failed: %s\n", "/", strerror(errno)); exit(0); } printf("mounted on %s:\n","/"); printf("\tf_bsize: %ld\n", vfs.f_bsize); printf("\tf_blocks: %ld\n", vfs.f_blocks); printf("\tf

sys_read syscall vs. int 0x80 in GNU Assembler [duplicate]

房东的猫 提交于 2019-12-11 08:42:32
问题 This question already has an answer here : What happens if you use the 32-bit int 0x80 Linux ABI in 64-bit code? (1 answer) Closed 2 years ago . I'm attempting to write a simple program which grabs a number of characters from stdin. For the sake of brevity, the relevant code is: mov $3, %rax # sys_read = 3 mov $0, %rbx # stdin fd = 0 mov $b, %rcx # '.lcomm b, 32' declared in .bss section mov $32,%rdx # size_t # syscall int $0x80 When I use int $0x80 the program functions as intended, however

Move memory pages per-thread in NUMA architecture

浪尽此生 提交于 2019-12-11 08:39:26
问题 i have 2 questions in one: (i) Suppose thread X is running at CPU Y. Is it possible to use the syscalls migrate_pages - or even better move_pages (or their libnuma wrapper) - to move the pages associated with X to the node in which Y is connected? This question arrises because first argument of both syscalls is PID (and i need a per-thread approach for some researching i'm doing) (ii) in the case of positive answer for (i), how can i get all the pages used by some thread? My aim is, move the

mount system call

时间秒杀一切 提交于 2019-12-11 08:07:28
问题 I am stuck at finding the correct usage of mount() system call which should be the replacment for the command $mount -t ext3 -oloop /test /mount Please help. Thanks 回答1: try: $ strace mount -t ext3 -oloop /test /mount And you will see that there are 2 number of system calls involved - one for setting the loopback block device and another to do the actual mount 来源: https://stackoverflow.com/questions/5095976/mount-system-call

What is the functionality of munmap, mmap

旧巷老猫 提交于 2019-12-11 07:04:44
问题 When I try to study some piece of code that deals with FPGA, I came across with munmap, mmap. I go through the manual provided here. I am still not understanding the purpose of this function. What exactly this does? 回答1: The manual is clear: mmap() creates a new mapping in the virtual address space of the calling process In short, it maps a chunk of file/device memory/whatever into the process' space, so that it can directly access the content by just accessing the memory. For example: fd =

When starting a system call, how are user-mode ss and esp saved, e.g. in linux?

╄→гoц情女王★ 提交于 2019-12-11 06:57:25
问题 I know user-mode ss/esp should be saved into the kernel-mode stack for later restore. The question is that to locate kernel-mode stack, ss/esp have to be loaded with the corresponding kernel-mode values first. Now it seems to me that user-mode ss/esp have been flushed. Then how does the hardware/system retrieve the user-mode ss/esp? Are user-mode ss and esp saved in some temporary places? Or the operation is supported by x86 circuit? 回答1: Think about what happens with the instruction pointer.