~ubuntu-branches/ubuntu/vivid/slurm-llnl/vivid

« back to all changes in this revision

Viewing changes to src/plugins/task/affinity/cpuset.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2009-09-24 23:28:15 UTC
  • mfrom: (1.3.4 upstream)
  • mto: (16.1.1 maverick)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090924232815-uu5ku2gqk7appy26
Tags: upstream-2.0.5
ImportĀ upstreamĀ versionĀ 2.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *  Copyright (C) 2007 The Regents of the University of California.
6
6
 *  Written by Don Albert <Don.Albert@Bull.com> and 
7
7
 *             Morris Jette <jette1@llnl.gov>
8
 
 *  LLNL-CODE-402394.
 
8
 *  CODE-OCEC-09-009. All rights reserved.
9
9
 *  
10
10
 *  This file is part of SLURM, a resource management program.
11
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
11
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
12
 *  Please also read the included file: DISCLAIMER.
12
13
 *  
13
14
 *  SLURM is free software; you can redistribute it and/or modify it under
14
15
 *  the terms of the GNU General Public License as published by the Free
99
100
        fd = open(file_path, O_RDONLY);
100
101
        if (fd < 0) {
101
102
                error("open(%s): %m", file_path);
102
 
        } else {
103
 
                rc = read(fd, mstr, sizeof(mstr));
104
 
                close(fd);
105
 
                if (rc < 1)
106
 
                        error("read(%s): %m", file_path);
107
 
                snprintf(file_path, sizeof(file_path), "%s/mems", path);
108
 
                fd = open(file_path, O_CREAT | O_WRONLY, 0700);
109
 
                if (fd < 0) {
110
 
                        error("open(%s): %m", file_path);
111
 
                        return -1;
112
 
                }
113
 
                rc = write(fd, mstr, rc);
114
 
                close(fd);
115
 
                if (rc < 1)
116
 
                        error("write(%s): %m", file_path);
 
103
                return -1;
 
104
        }
 
105
        rc = read(fd, mstr, sizeof(mstr));
 
106
        close(fd);
 
107
        if (rc < 1) {
 
108
                error("read(%s): %m", file_path);
 
109
                return -1;
 
110
        }
 
111
        snprintf(file_path, sizeof(file_path), "%s/mems", path);
 
112
        fd = open(file_path, O_CREAT | O_WRONLY, 0700);
 
113
        if (fd < 0) {
 
114
                error("open(%s): %m", file_path);
 
115
                return -1;
 
116
        }
 
117
        rc = write(fd, mstr, rc);
 
118
        close(fd);
 
119
        if (rc < 1) {
 
120
                error("write(%s): %m", file_path);
 
121
                return -1;
117
122
        }
118
123
 
119
124
        /* Delete cpuset once its tasks complete.
126
131
        }
127
132
        rc = write(fd, "1", 2);
128
133
        close(fd);
 
134
        if (rc < 1) {
 
135
                error("write(%s): %m", file_path);
 
136
                return -1;
 
137
        }
129
138
 
130
139
        /* Only now can we add tasks.
131
140
         * We can't add self, so add tasks after exec. */
134
143
}
135
144
 
136
145
int     slurm_set_cpuset(char *base, char *path, pid_t pid, size_t size, 
137
 
                const cpu_set_t *mask)
 
146
                         const cpu_set_t *mask)
138
147
{
139
148
        int fd, rc;
140
149
        char file_path[PATH_MAX];
169
178
        } else {
170
179
                rc = read(fd, mstr, sizeof(mstr));
171
180
                close(fd);
172
 
                if (rc < 1)
 
181
                if (rc < 1) {
173
182
                        error("read(%s): %m", file_path);
 
183
                        return -1;
 
184
                }
174
185
                snprintf(file_path, sizeof(file_path), "%s/mems", path);
175
186
                fd = open(file_path, O_CREAT | O_WRONLY, 0700);
176
187
                if (fd < 0) {
179
190
                }
180
191
                rc = write(fd, mstr, rc);
181
192
                close(fd);
182
 
                if (rc < 1)
 
193
                if (rc < 1) {
183
194
                        error("write(%s): %m", file_path);
 
195
                        return -1;
 
196
                }
184
197
        }
185
198
 
186
199
        /* Delete cpuset once its tasks complete.
267
280
        int fd, i, max_node;
268
281
        ssize_t rc;
269
282
 
270
 
        snprintf(file_path, sizeof(file_path), "%s/mems", CPUSET_DIR);
271
 
        fd = open(file_path, O_CREAT | O_RDONLY, 0700);
 
283
        snprintf(file_path, sizeof(file_path), "%s/mems", path);
 
284
        fd = open(file_path, O_CREAT | O_RDWR, 0700);
272
285
        if (fd < 0) {
273
286
                error("open(%s): %m", file_path);
274
287
                return -1;